Hide WooCommerce Layered Nav Filters in Categories & Subcategories

Layered Nav filters are a must have on your eCommerce website or easy to use online catalog. They give your visitors the ability to customize their engagement with your website to help them narrow down their product search hoping to find the one that matches their needs.

Unfortunately, simply adding a WooCommerce Layered Nav widget in the shop sidebar leaves your categories and subcategories with product filters where you don’t want to see them. Filters are generally used when you have a selection of products, not when looking at Subcategories.

The Solution

To make it work, you’ll need to work with three things:

  1. Widget Logic plugin
  2. Edit functions.php
  3. Use conditional logic statement in the WooCommerce Layered Nav widget

1. Download & Install the Widget Logic Plugin

You can install this plugin within WordPress > Plugins > Add New and search for “Widget Logic” and clicking install or by downloading it directly from its plugin page on WordPress.

Screen Shot 2015-02-13 at 5.57.56 PM

2. Edit functions.php and Add this Custom Function

In your WordPress admin, go to Appearance > Edit and click on functions.php on the file list on the right. Scroll to the bottom of your file and add the follow lines of PHP code:

(I recommend editing your child theme’s function.php)

 

BTW, I found this code here, written by Matthew Price

3. Customize a WooCommerce Layered Nav Widget in Your Shop Sidebar

After you configure the attribute, in the Widget logic text area, use the following conditional statement:

 

Screen Shot 2015-02-13 at 5.56.32 PM

4. Test it Now, See it in Action

Now, check your category and subcategory pages. You shouldn’t see any filter there. Then check a category without any subcategories and only products. You should only see the filter there.

Before

Screen Shot 2015-02-13 at 5.51.59 PM

AfterScreen Shot 2015-02-13 at 5.47.05 PM

Here’s another example of using Layered Nav filters

Screen Shot 2015-02-13 at 6.00.00 PM

Let me know if you found this tutorial useful by commenting or sharing it.

 

 

Tags

2 comments

Leave a Reply

Your email address will not be published.

top