How To Filter By Category?
Divi Ajax Filter (and BodyCommerce/Machine) offer two ways for you to Filter by category. Remember to update or publish your work as you go. Follow the images below.
1.) Standard Filtering.
After creating your categories you will need to build a page with the .FILTER POSTS Module and .ARCHIVE Module. Inside the .FILTER POSTS Module you will need to add a New Filter Item and assign it to filter by Category using the Main Options. Using the Category Filter Options you will be able to refine the filter to search Only Parent Categories, Only Sub Categories of Selected Category (you define the slug of the parent category below), Sub Categories of the current category (this is when you are building the category page itself) or All.
2.) Conditional Categories.
If you want to have two filters and one be updated based on the selection of the parent categories follow these steps.
Step 1: Add Parent Category Filter.
Add the Parent Category Filter defining it to show ONLY parent categories. After doing this you will need to set the Conditional ID and Name.
Step 2: Add Subcategory Filter.
Add a second Filter Item defining it to be the Subcategory Filter. To do this you will need to edit the Main Options, Category Filter Options and Logic. Make sure that it shows all for the category display mode. When defining the logic, enable the logic and make sure these conditions are met.
- Relation = ALL
- Parent Category (defined above) does not equal
- Parent Category (defined above) is not empty
Now this filter will be updated based on the parent category selection.