Filter Products by Category and Same Tag in WooCommerce

The code in this download adds filters to sort products by category and category with the same tag or only tag. The filters enable users to :

  1. Only display the same level of category when selected, not all children.
  2. Display products by same tag without selecting a category.
  3. Display any level of category with or without selecting a tag.

Works for parent and child categories with any level of children including child, child of child etc.

Uses Ajax so there’s no URL refresh.

Code Installation

By following these Installation steps, you are provided an AJAX-powered product filter on your WooCommerce shop page, allowing users to filter products without refreshing the page.

Ajax

  1. From the folder named ajax, upload the woocommerce folder to your child theme folder.
  2. Copy and paste the PHP code from the functions file to the end of your child themes functions file.
  3. Copy and paste the CSS from the style.css file to the end of your child themes stylesheet and clear caching.

Note : The woocommerce folder includes a content-product.php file which outputs links for categories and tags. delete the file if you don’t want taxonomy links added to your products on shop page archives.

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.