/** * Set default product sorting for WooCommerce */ add_filter('woocommerce_default_catalog_orderby', 'custom_default_product_sorting'); function custom_default_product_sorting() { return 'date'; // Change to: 'menu_order', 'popularity', 'rating', 'price', 'price-desc' } /** * Force WooCommerce to use this order in queries */ add_filter('woocommerce_get_catalog_ordering_args', 'custom_catalog_ordering_args'); function custom_catalog_ordering_args($args) { $args['orderby'] = 'date'; // Must match the option above $args['order'] = 'DESC'; // 'ASC' for ascending, 'DESC' for descending return $args; } /** * Remove the sorting dropdown (optional) */ add_action('init', 'remove_woocommerce_sorting_dropdown'); function remove_woocommerce_sorting_dropdown() { remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30); }
Skip to content