WooCommerce: Remove specific category from category listing on shop page?

In this tutorial, We Will learn how to remove a specific category from category listing on shop page. First of all you need to enable category listing from WooCommerce’s settings, since it only shows products on shop page by default.


Go to admin panel of your site and select the option to show categories only or categories and products both.


Now if you go to shop page again you will see products as well as categories.


Now I want to remove a specific category from this i.e. category 1. To do this first of all note the category slug of that category.

You can find category slug of a category from categories under products in your admin panel.


Now all you have to do is add following lines of code to your theme’s functions.php File.

add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
function get_subcategory_terms( $terms, $taxonomies, $args ) {
  $new_terms = array();
  // if a product category and on the shop page
  if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_shop() ) {
    foreach ( $terms as $key => $term ) {
      if ( ! in_array( $term->slug, array( 'category-1' ) ) ) {
        $new_terms[] = $term;
    $terms = $new_terms;
  return $terms;

Replace the category slug in code with slug of your category. E.g: array( ‘category-1′ )

Now Go to your Shop page and You will see specific category has been removed from there.




I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

Leave a Comment

Your email address will not be published. Required fields are marked *