diff --git a/includes/class-wc-template-loader.php b/includes/class-wc-template-loader.php index f9b73718f4c..93c2bbc3f1c 100644 --- a/includes/class-wc-template-loader.php +++ b/includes/class-wc-template-loader.php @@ -444,6 +444,7 @@ class WC_Template_Loader { // Remove actions and self to avoid nested calls. remove_action( 'pre_get_posts', array( wc()->query, 'product_query' ) ); + WC()->query->remove_ordering_args(); } self::$in_content_filter = false; diff --git a/includes/shortcodes/class-wc-shortcode-products.php b/includes/shortcodes/class-wc-shortcode-products.php index ce01021c1c1..84c2b163cdc 100644 --- a/includes/shortcodes/class-wc-shortcode-products.php +++ b/includes/shortcodes/class-wc-shortcode-products.php @@ -525,10 +525,8 @@ class WC_Shortcode_Products { set_transient( $transient_name, $results, DAY_IN_SECONDS * 30 ); } } - // Remove ordering query arguments. - if ( ! empty( $this->attributes['category'] ) ) { - WC()->query->remove_ordering_args(); - } + // Remove ordering query arguments which may have been added by get_catalog_ordering_args. + WC()->query->remove_ordering_args(); return $results; }