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 :
- Only display the same level of category when selected, not all children.
- Display products by same tag without selecting a category.
- 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.
![](https://wpsites.net/wp-content/uploads/2024/05/child-child-category-no-parent-same-tag-480x300.png)
![](https://wpsites.net/wp-content/uploads/2024/05/parent-category-no-tag-480x300.png)
![](https://wpsites.net/wp-content/uploads/2024/05/parent-category-same-tag-480x300.png)
![](https://wpsites.net/wp-content/uploads/2024/05/sub-category-no-parent-480x300.png)
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
- From the folder named ajax, upload the woocommerce folder to your child theme folder.
- Copy and paste the PHP code from the functions file to the end of your child themes functions file.
- 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.
Leave a Reply
You must be logged in to post a comment.