Support » Plugins and Hacks » [Woocommerce] Change Order of Catalog page to Ascending

  • So I had this worked out last night.. I thought and for some reason went to check it this morning and it no longer works.. Can anyone chime in on where I’m going wrong? Thx

    add_filter('woocommerce_get_catalog_ordering_args', 'am_woocommerce_catalog_orderby');
    function am_woocommerce_catalog_orderby( $args ) {
        $args['date'] = 'meta_value_num';
        $args['order'] = 'ASC';
        return $args;
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • Nevermind, think I nailed it here:

    // Change the Default sorting in catalog
    add_filter('woocommerce_get_catalog_ordering_args', 'am_woocommerce_catalog_orderby');
    function am_woocommerce_catalog_orderby( $args ) {
        $args['date'] = 'meta_value_num';
        $args['orderby'] = 'ASC';
        return $args;
    }

    Notice the 2nd arg is now ‘orderby’

    Hmm I tried your code and it didn’t work I put it on the functions page.

    I ended up finding this. and this worked.

    add_filter('woocommerce_get_catalog_ordering_args', 'am_woocommerce_catalog_orderby');
    function am_woocommerce_catalog_orderby( $args ) {
    	$args['orderby'] = 'date';
    	$args['order'] = 'desc';
    	$args['meta_key'] = '';
        return $args;
    }

    ahh yes, you have your order set to decending, mine is set to ascending

    Note this line in your code:
    $args['order'] = 'desc';

    Great! Thanks!

    Hi, can we sort the products beside title, date, price? Like based on stock maybe?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Woocommerce] Change Order of Catalog page to Ascending’ is closed to new replies.