WordPress.org

Ready to get started?Download WordPress

Forums

[Woocommerce] Change Order of Catalog page to Ascending (7 posts)

  1. DesignLoud
    Member
    Posted 1 year ago #

    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;
    }
  2. DesignLoud
    Member
    Posted 1 year ago #

    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'

  3. silentfxx
    Member
    Posted 1 year ago #

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

  4. silentfxx
    Member
    Posted 1 year ago #

    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;
    }
  5. DesignLoud
    Member
    Posted 1 year ago #

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

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

  6. silentfxx
    Member
    Posted 1 year ago #

    Great! Thanks!

  7. nyenius
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic