Home Forums Basel support forum Remove some elements from filter "Sort by"

Remove some elements from filter "Sort by"

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28107

    svaldesm
    Participant

    Hi,

    Sorry for all the questions but I’m setting my store up and running, hope just bother you guys for a week and then you’ll never hear from me again.

    I would like to remove some elements (for example, “Default”, “Popularity”) from the Sort by filter.

    I think it’s made via a functions.php code but so far haven’t been able to make it work.

    Thanks!!

    #28108

    svaldesm
    Participant

    OK I already found the solution.
    In case someone else is looking, this worked for me:

    
    function my_woocommerce_catalog_orderby( $orderby ) {
        unset($orderby["menu-order"]);
    	unset($orderby["popularity"]);
        unset($orderby["rating"]);
        return $orderby;
    }
    add_filter( "woocommerce_catalog_orderby", "my_woocommerce_catalog_orderby", 20 );
    
    #28109

    svaldesm
    Participant

    Also if you would like to set one as default, this works:

    // Set date as default order
    function default_orderby() {
        return('date');
    }
    add_filter( "woocommerce_default_catalog_orderby", "default_orderby", 20 );
    #28183

    Artem Temos
    Keymaster

    Hi,

    Great, we are glad that you have found the solution.

    Regards

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)