• 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)
  • Plugin Support Iván Sosa

    (@ivansosa)

    Hi there,

    The filtering order depends on WooCommerce and is currently not possible.
    The code you are using makes it possible to sort products within a category page, but not in filters.

    Have a nice day!

    Thread Starter startechmarketing

    (@startechmarketing)

    Ok thanks I reached out to them because the filter code I tried does not work on the shop page

    Plugin Support Alessio Torrisi

    (@alessio91)

    Hi there,

    unfortunately we can’t support on this request.

    We remain at your disposal for any question about the pugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘sorting specific category by date ascending’ is closed to new replies.