sorting specific category by date ascending
-
I tried to add some filter code to sort by date ascending on the “training” category but when I chose the category filter the url defaults to the search, – we use an event that creates products as events, the ideal is sorting the training by the training date
my filter code is below but maybe is a way for me to customize the filter set in the url when training is click?
please let me know if you have ideas, I will keep googling
add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_catalog_ordering_args', 20, 1 ); function custom_catalog_ordering_args( $args ) { $product_categories = array('training'); // <== HERE define your product category // Only for defined product category archive page if( ! is_product_category($product_categories) ) return $args; // Set default ordering to title $args['orderby'] = 'date'; if( $args['orderby'] == 'title' ) $args['order'] = 'ASC'; // Set order by DESC return $args; }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘sorting specific category by date ascending’ is closed to new replies.