• Resolved sdschub

    (@sdschub)


    Hi there

    I am trying to remove the ‘Sort by’ dropdown on a Woocommerce Shop page

    I am using this code in my functions.php

    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );

    However, it doesn’t seem to work for me? I have the dropdown hidden in CSS currently but I’d prefer if it wasn’t there at all rather than it being there but hidden.

    Thanks.

    • This topic was modified 5 years, 7 months ago by sdschub.
    • This topic was modified 5 years, 7 months ago by James Huff.
Viewing 15 replies - 1 through 15 (of 24 total)
  • Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @sdschub!

    Use the following CSS code:

    .woocommerce-ordering {
      display: none;
    }

    Cheers!

    Thread Starter sdschub

    (@sdschub)

    Thanks @rynald0s. However I am looking for a way to do it not in CSS as I want the code to not show in html if possible. Thanks!

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @sdschub!

    Use:

    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );

    Cheers!

    Thread Starter sdschub

    (@sdschub)

    Thanks @rynald0s. I tried that but unfortunately it didn’t seem to make a difference. Not sure why.

    Plugin Support Missy a11n

    (@m155y5)

    Automattic Happiness Engineer

    @sdschub – Which theme are you using? And how are you adding it to the theme (via a plugin or editing the actual functions file)?

    If you’re adding this snippet on to other functions included with the theme, maybe check to see if there is another function that might be overriding it.

    Thread Starter sdschub

    (@sdschub)

    @m155y5 I am using the shop-isle theme. I am adding the code by editing the functions.php in the child theme.

    I am not sure how I can check if another function is overriding it but if I put the above code at the bottom part of my functions.php should that override it? Because I did put it at the bottom of my functions.php however it was still showing.

    Thanks!

    Hi @sdschub,

    I am not sure how I can check if another function is overriding it but if I put the above code at the bottom part of my functions.php should that override it?

    There is no real way to override a function unless you code the other function out, or specifically state to ignore another function. It may be the Shop-isle theme has a built in function to show the method, and thus the functions are not working. You would most likely have to stick to the CSS method, however you can reach out to your theme provider to see if they have a way of forcing the function to work in the theme.

    I am having the same problem. Added the code to my child theme functions.php but the “sort by” thing is still there.
    this is all the code I have there:

    /* Remove "Default Sorting" Dropdown @ WooCommerce Shop & Archive Page*/
    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
    
    /*Remove Additional Information Tab @ WooCommerce Single Product Page*/
     
    add_filter( 'woocommerce_product_tabs', 'bbloomer_remove_product_tabs', 98 );
     
    function bbloomer_remove_product_tabs( $tabs ) {
        unset( $tabs['additional_information'] ); 
        return $tabs;
    }
    
    /* remove you are here */
    add_filter('avia_breadcrumbs_args', 'avia_remove_you_are_here_breadcrumb', 10, 1);
    function avia_remove_you_are_here_breadcrumb($args){
    $args['before'] = "";
    return $args;
    }
    
    add_filter('avia_breadcrumbs_trail', 'avia_breadcrumbs_args_mod', 10, 2);
    function avia_breadcrumbs_args_mod($trail, $args){
    	unset($trail[0]);
    	return $trail;
    }

    any ideas what the problem might be? I am on a developer site.
    thanks for your help
    Nancy

    Plugin Support Missy a11n

    (@m155y5)

    Automattic Happiness Engineer

    @sdschub

    The code we sent you earlier is for the Storefront theme. Please try this one instead:

    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );

    @einstein-green – Which theme are you using, please? ?? That will help troubleshoot.

    thanks for your help
    I am using Enfold

    that code did not work for me either ??

    Thread Starter sdschub

    (@sdschub)

    Thanks @m155y5 . Unfortunately that code does not work for me. It is the original code that I used in the beginning and did not work. ??

    Any other ideas?

    Plugin Support Missy a11n

    (@m155y5)

    Automattic Happiness Engineer

    @einstein-green – I believe that the Enfold theme does include that function somewhere, so it might be causing an issue. You might reach out to the Kriesi support team to see if they have any solutions for you.

    Another option to see if it’s the theme causing a conflict with the function is to try switching your theme to the Storefront theme and see if it works correctly.

    Hi @einstein-green,

    We have not heard back from you in a while, so I am going to go ahead and close this thread. If you are still experiencing the issue please reply to this thread. Otherwise open a new thread and let us know.

    Cheers!

    I came across the same problem. To remove the action, remove_action must be placed inside a hook, rather than directly inside functions.php. In my case, I used before_woocommerce_init like so:

    add_action( 'before_woocommerce_init', function() {
    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
    } );
Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘Removing Sort by on WooCommerce Shop Page’ is closed to new replies.