Woocommerce How To Remove Category From Shop

WooCommerce: How to Remove Categories from Your Shop Page (Beginner’s Guide)

So, you’ve built your awesome online store with WooCommerce, populated it with products, and organized them neatly into categories. But now you’re staring at your shop page and thinking, “Wait, I don’t want *all* these categories showing up here!” Maybe you want to declutter, highlight specific product types, or create a more curated shopping experience. Don’t worry, you’re not alone! This guide will walk you through several easy ways to remove categories from your WooCommerce shop page without touching any complex code (unless you want to!).

Think of it like this: you have a physical store. You might have “Seasonal Decorations” stored in the back room. While you *have* the decorations (product category), you don’t want them cluttering up the main display floor (shop page) unless it’s actually a holiday. That’s what we’re achieving here.

Why Remove Categories From Your Shop Page?

Before we dive in, let’s quickly cover why you might want to do this:

    • Clean & Focused Presentation: Reduces visual clutter, making your main offerings more prominent. Imagine a clothing store highlighting only “Summer Collection” during the summer months.
    • Targeted Marketing: Promote specific product lines or categories for a sale or special event. Want to focus on your new line of eco-friendly products? Remove other categories to draw attention.
    • Improved User Experience: Makes it easier for customers to find what they’re looking for, leading to increased sales. Fewer distractions mean more conversions!
    • Hide Under Development Categories: Keep categories hidden until products are ready. Useful for staging new product launches.

    Method 1: The WooCommerce Category Display Setting (Easiest)

    WooCommerce has a built-in setting that controls what appears on your shop page. This is the simplest and often best method for most users.

    1. Go to: *WooCommerce > Settings > Products > Display*.

    2. Find the “Shop Page Display” option. This setting controls what gets displayed on your main shop page.

    3. Choose from the dropdown:

    • “Show products”: This displays only your products. No categories will be shown. This is what you want if you want a clean product grid.
    • “Show categories”: This displays only the categories. This is less common for the main shop page, but might be useful for a dedicated category landing page.
    • “Show categories & products”: This is the default, displaying both categories and products.
    • 4. Save your changes! Click the “Save changes” button at the bottom of the page.

    Example: If you’re running a “Back to School” promotion on your “School Supplies” category and want to temporarily hide all other categories, select “Show products.” Only products within *all* categories will show.

    Limitation: This method doesn’t allow you to choose *specific* categories to hide. It’s an “all or nothing” approach to categories. For more granular control, read on!

    Method 2: Using a WooCommerce Shortcode (More Control)

    WooCommerce shortcodes are bits of code you can embed in pages or posts to display specific elements. We can use the `[products]` shortcode with category attributes to only display products from *certain* categories. This allows you to create custom shop-like pages showing only the product types you desire.

    1. Create a new page (or edit an existing one). This will be your new “curated” shop page.

    2. Add the `[products]` shortcode. This is where the magic happens.

    3. Use the `category` attribute to specify which categories to include. Separate multiple categories with commas.

    Example: Let’s say you want to create a page showing only “T-shirts” and “Hoodies”. You’d use this shortcode:

    [products category=”t-shirts, hoodies”]

    How it works:

    Finding Your Category Slug:

    A “slug” is the URL-friendly version of your category name. To find it:

    1. Go to: *Products > Categories*.

    2. Hover over the category you want to use.

    3. Look at the URL in the bottom left corner of your browser (or right-click and “Copy Link Address”). It will look something like: `…/wp-admin/term.php?taxonomy=product_cat&tag_ID=123&post_type=product&wp_http_referer=%2Fwp-admin%2Fedit-tags.php%3Ftaxonomy%3Dproduct_cat&wp-nonce=…`

    4. The category slug is the bit after `taxonomy=product_cat&tag_ID=`. *However, this only shows the category ID, not the slug.*. Click ‘Edit’ on the category.

    5. The slug is in the ‘Slug’ field.

    Important: Use the *slug*, not the category name, in the shortcode!

    More Shortcode Attributes: The `[products]` shortcode has other attributes you can use, like:

    • `limit`: The number of products to display. `[products category=”t-shirts” limit=”8″]`
    • `columns`: The number of columns in the product grid. `[products category=”t-shirts” columns=”4″]`
    • `orderby`: How to order the products (e.g., `popularity`, `date`, `price`). `[products category=”t-shirts” orderby=”price”]`
    • `order`: Ascending (`ASC`) or descending (`DESC`) order. `[products category=”t-shirts” orderby=”price” order=”DESC”]`

    Example: Showing the 12 most popular t-shirts in 3 columns:

    [products category=”t-shirts” limit=”12″ columns=”3″ orderby=”popularity”]

    Method 3: Hiding Categories with Custom Code (Advanced)

    This method involves adding custom PHP code to your theme’s `functions.php` file (or a child theme’s `functions.php` file). Use this method with caution! Incorrect code can break your site. It’s always best practice to use a child theme so theme updates don’t overwrite your changes.

    1. Create a Child Theme (Strongly Recommended): This protects your customizations from being overwritten when you update your main theme.

    2. Edit your Child Theme’s `functions.php` file. You can access this through *Appearance > Theme Editor* (if available) or using an FTP client.

    3. Add the following code snippet:

     <?php add_filter( 'woocommerce_product_subcategories_args', 'hide_specific_categories_from_shop' ); 

    function hide_specific_categories_from_shop( $args ) {

    // Array of category IDs to hide

    $hidden_categories = array( 23, 45, 67 ); // Replace with your actual category IDs

    $args[‘exclude’] = $hidden_categories;

    return $args;

    }

    How it works:

    • `add_filter(‘woocommerce_product_subcategories_args’, ‘hide_specific_categories_from_shop’);` hooks into the WooCommerce filter that controls how product subcategories are displayed.
    • `hide_specific_categories_from_shop()` is a custom function that modifies those arguments.
    • `$hidden_categories = array(23, 45, 67);` This is where you specify the *category IDs* you want to hide. Replace `23, 45, 67` with the actual IDs of the categories you want to hide. You can find the category ID by editing the category (see “Finding Your Category Slug” above; look at the URL – `tag_ID` is the ID).
    • `$args[‘exclude’] = $hidden_categories;` This tells WooCommerce to exclude those categories.

    Important Considerations:

    • Child Theme: Using a child theme is crucial to prevent losing your changes during theme updates.
    • Category IDs: Make sure you use the correct category IDs, not the slugs.
    • Testing: Test thoroughly after adding the code to ensure it’s working as expected and doesn’t break anything.
    • Reversibility: If things go wrong, you can simply remove or comment out the code from your `functions.php` file.

    Example: If you want to hide categories with IDs 5, 10, and 15, the code would look like this:

     <?php add_filter( 'woocommerce_product_subcategories_args', 'hide_specific_categories_from_shop' ); 

    function hide_specific_categories_from_shop( $args ) {

    // Array of category IDs to hide

    $hidden_categories = array( 5, 10, 15 ); // Replace with your actual category IDs

    $args[‘exclude’] = $hidden_categories;

    return $args;

    }

    Choosing the Right Method

    • Easiest: For a simple “show products only” solution, use Method 1 (WooCommerce settings).
    • Most Flexible: For creating custom “shop” pages with specific categories, use Method 2 (shortcodes).
    • For Hiding Specific Categories on the Main Shop Page Only: Use Method 3 (custom code), but *only if you’re comfortable with code and using a child theme*.

By using one of these methods, you can easily remove unwanted categories from your WooCommerce shop page and create a better shopping experience for your customers. Good luck!

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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