How to Show Different Filters per Category in WOOF (Dynamic Filtering)
Learn how to display different filter sets based on product categories, create dependent filtering, and customize filters for the WooCommerce Shop page.
The Problem
By default, WOOF shows the same filters across all pages. However, different product categories often need different filter options:
Example scenarios:
- Electronics category: Show Brand, Screen Size, Storage, RAM
- Clothing category: Show Size, Color, Material, Style
- Furniture category: Show Material, Color, Dimensions, Room Type
- Shop page (main archive): Show only Categories, Price Range, Featured brands
Current limitation: All filter options remain global, even after a user selects a category, making the interface cluttered with irrelevant filters.
What you’ll learn:
- How to enable dependent/conditional filtering (filters update based on selection)
- How to show different filters per product category
- How to create custom filter sets for the Shop page
- How to use Widget Logic for advanced visibility control
Solution 1: Enable Dependent Filtering (AJAX Redraw)
The first step is enabling AJAX form redrawing, which updates filters dynamically when users make selections.
For Widgets:
- Go to Appearance → Widgets
- Find your WOOF widget
- Enable the option “Form AJAX redrawing”
This makes filters update automatically after each selection, showing only relevant options.
For Shortcodes:
Add the ajax_redraw attribute to your WOOF shortcode:
[woof ajax_redraw="1"]
What this does:
- When user selects “Wheel” → other filters automatically update
- Only shows Sub Types, Materials, Colors available for Wheel
- Reduces clutter by hiding irrelevant options
Documentation: https://products-filter.com/shortcode/woof
Solution 2: Category-Based Filter Visibility (Custom Shortcode)
This solution creates a dynamic shortcode that displays different filters depending on the current product category.
Step 1: Create Custom Shortcode
Add this code to your child theme’s functions.php:
/**
* Dynamic WOOF shortcode that shows different filters per category
* Usage: [woof_dynamic]
*/
add_shortcode('woof_dynamic', function () {
// Check if WOOF is active
if (!function_exists('woof_shortcode')) {
return '<!-- WOOF plugin not active -->';
}
// Get current category
$term = get_queried_object();
// Check if we're on a product category page
if (!$term || !isset($term->taxonomy) || $term->taxonomy !== 'product_cat') {
return do_shortcode('[woof]'); // Show default filters
}
// Get category slug
$cat = strtolower($term->slug);
// Define which filters to show for each category
$filters_map = [
'wheel' => ['pa_sub-type', 'pa_material', 'pa_colour', 'pa_size'],
'lingerie' => ['pa_size', 'pa_colour', 'pa_material'],
'massage-candles' => ['pa_type', 'pa_material', 'pa_brand'],
'electronics' => ['pa_brand', 'pa_screen-size', 'pa_storage'],
'clothing' => ['pa_size', 'pa_color', 'pa_material', 'pa_style'],
'furniture' => ['pa_material', 'pa_color', 'pa_dimensions', 'pa_room'],
];
// If category not in map, show default filters
if (!isset($filters_map[$cat])) {
return do_shortcode('[woof]');
}
// Build shortcode with specific filters for this category
$taxonomies = implode(',', $filters_map[$cat]);
return do_shortcode('[woof tax_only="' . esc_attr($taxonomies) . '" ajax_redraw="1"]');
});
Step 2: Use the Shortcode
Replace your existing [woof] shortcode with:
[woof_dynamic]
Place this shortcode in:
- Widget areas (Text/HTML widget)
- Page builder blocks (Elementor, Divi, etc.)
- Theme template files:
<?php echo do_shortcode('[woof_dynamic]'); ?>
Step 3: Configure Your Categories
Update the $filters_map array with your actual:
- Category slugs (e.g., ‘wheel’, ‘electronics’)
- Attribute slugs (e.g., ‘pa_brand’, ‘pa_size’)
Finding your slugs:
Category slugs:
- Go to Products → Categories
- Hover over a category name
- Look at the URL:
...tag_ID=123&taxonomy=product_cat&post_type=product - Or edit the category and look at the slug field
Attribute slugs:
- Go to Products → Attributes
- They start with
pa_followed by the attribute name - Examples:
pa_color,pa_size,pa_brand,pa_material
Solution 3: Custom Filters for Shop Page
The main WooCommerce Shop page needs different handling since it’s not a category archive.
Combined Solution: Shop Page + Category Pages
This code handles both the Shop page and individual category pages:
/**
* Dynamic WOOF shortcode with Shop page support
* Shows minimal filters on Shop, full filters on categories
*/
add_shortcode('woof_dynamic', function () {
if (!function_exists('woof_shortcode')) {
return '';
}
// Shop page (main product archive) - show minimal filters
if (is_shop() AND !is_product_category() AND !is_product_tag()) {
return do_shortcode('[woof tax_only="product_cat,pa_colour" by_price="1" ajax_redraw="1"]');
}
// Product category pages - show category-specific filters
$term = get_queried_object();
if ($term AND isset($term->taxonomy) AND $term->taxonomy === 'product_cat') {
$cat = strtolower($term->slug);
// Define filters for each category
$filters_map = [
'wheel' => ['pa_sub-type', 'pa_material', 'pa_colour', 'pa_size'],
'lingerie' => ['pa_size', 'pa_colour', 'pa_material'],
'massage-candles' => ['pa_type', 'pa_material', 'pa_brand'],
'electronics' => ['pa_brand', 'pa_screen-size', 'pa_storage'],
'clothing' => ['pa_size', 'pa_color', 'pa_material', 'pa_style'],
];
if (isset($filters_map[$cat])) {
$taxonomies = implode(',', $filters_map[$cat]);
return do_shortcode('[woof tax_only="' . esc_attr($taxonomies) . '" ajax_redraw="1"]');
}
}
// Fallback - show all filters
return do_shortcode('[woof ajax_redraw="1"]');
});
What this code does:
- On Shop page: Shows only Categories, Color, and Price filters
- On category pages: Shows category-specific filters from mapping
- On other pages: Shows default filters
Customize Shop page filters: Change this line to show different filters on Shop page:
[woof tax_only="product_cat,pa_colour" by_price="1" ajax_redraw="1"]
Available parameters:
tax_only="product_cat,pa_brand"– Show only these taxonomiesby_price="1"– Show price range filterby_only="product_cat,pa_brand"– Alternative to tax_onlyajax_redraw="1"– Enable dynamic updates
Solution 4: Widget Logic for Conditional Visibility
If you prefer using widgets instead of shortcodes, you can control widget visibility with conditional logic.
Step 1: Install Widget Logic Plugin
Choose one of these plugins:
- Widget Logic: https://wordpress.org/plugins/widget-logic/
- Show Widget by Logic: https://github.com/realmag777/Show-WordPress-Widget-by-Logic
Step 2: Create Multiple WOOF Widgets
- Go to Appearance → Widgets
- Add multiple WOOF widgets to your sidebar
- Configure each widget with different filters
Step 3: Add Conditional Logic
For each widget, add visibility conditions:
Show only on Wheel category:
is_product_category('wheel')
Show only on Lingerie category:
is_product_category('lingerie')
Show only on Shop page:
is_shop() AND !is_product_category()
Show on multiple categories:
is_product_category(array('wheel', 'lingerie', 'massage-candles'))
Show everywhere except Shop page:
!is_shop()
Show on Electronics or Computers categories:
is_product_category('electronics') || is_product_category('computers')
Real-World Examples
Example 1: Adult Products Store
$filters_map = [
'wheel' => ['pa_type', 'pa_material', 'pa_color', 'pa_power-source', 'pa_waterproof'],
'lingerie' => ['pa_size', 'pa_color', 'pa_style', 'pa_material'],
'oil' => ['pa_type', 'pa_brand', 'pa_ingredients', 'pa_volume'],
'toys' => ['pa_category', 'pa_material', 'pa_size', 'pa_color'],
];
Example 2: Electronics Store
$filters_map = [
'laptops' => ['pa_brand', 'pa_processor', 'pa_ram', 'pa_storage', 'pa_screen-size'],
'smartphones' => ['pa_brand', 'pa_storage', 'pa_ram', 'pa_camera', 'pa_battery'],
'headphones' => ['pa_brand', 'pa_type', 'pa_connection', 'pa_noise-cancelling'],
'cameras' => ['pa_brand', 'pa_megapixels', 'pa_sensor-size', 'pa_video-quality'],
];
Example 3: Fashion Store
$filters_map = [
'mens-clothing' => ['pa_size', 'pa_color', 'pa_material', 'pa_brand', 'pa_style'],
'womens-clothing' => ['pa_size', 'pa_color', 'pa_material', 'pa_brand', 'pa_occasion'],
'shoes' => ['pa_size', 'pa_color', 'pa_brand', 'pa_type', 'pa_material'],
'accessories' => ['pa_color', 'pa_material', 'pa_brand', 'pa_type'],
];
Example 4: Furniture Store
$filters_map = [
'bedroom' => ['pa_type', 'pa_material', 'pa_color', 'pa_style', 'pa_size'],
'living-room' => ['pa_type', 'pa_material', 'pa_color', 'pa_seating-capacity'],
'office' => ['pa_type', 'pa_material', 'pa_color', 'pa_ergonomic'],
'outdoor' => ['pa_type', 'pa_material', 'pa_weather-resistant', 'pa_color'],
];
Advanced: Include Price and Categories
If you want to show price range and categories in addition to attributes:
// On category pages, add price and allow category drill-down
if (isset($filters_map[$cat])) {
$taxonomies = implode(',', $filters_map[$cat]);
return do_shortcode('[woof tax_only="product_cat,' . esc_attr($taxonomies) . '" by_price="1" ajax_redraw="1"]');
}
Parameters explanation:
product_cat– Shows category filter for drill-downby_price="1"– Shows price range sliderajax_redraw="1"– Updates filters dynamically
Troubleshooting
Filters not updating dynamically
Problem: Filters remain static after selection
Solution:
- Make sure
ajax_redraw="1"is in your shortcode - Enable “Form AJAX redrawing” in widget settings
- Check JavaScript console for errors
Wrong filters showing on category
Problem: Category shows incorrect filter set
Solution:
- Verify category slug is correct (check URL or category settings)
- Use lowercase in
$filters_maparray - Check if category exists in your mapping
Filters not appearing at all
Problem: No filters visible on page
Solution:
- Verify attribute slugs start with
pa_(e.g.,pa_colornotcolor) - Check if attributes are assigned to products in that category
- Use
[woof]temporarily to see if basic shortcode works
Shop page shows category filters
Problem: Shop page showing wrong filter set
Solution:
- Verify
is_shop()condition is first in your code - Check that
!is_product_category()is included - Clear all caches (WordPress, server, browser)
Attribute slugs not working
Problem: Filters not showing for specific attributes
Solution:
- Go to Products → Attributes to find correct slugs
- Remember to use
pa_prefix (WooCommerce requirement) - Check spelling:
pa_colourvspa_color
Code not working after adding
Problem: White screen or errors after adding code
Solution:
- Check PHP syntax errors in error log
- Make sure you’re editing child theme’s functions.php
- Verify all brackets and quotes are closed
- Remove code and add it back line by line
Performance Considerations
AJAX redraw impact:
- Each selection triggers AJAX request
- More products = longer response time
- Solution: Use caching and optimize database
Multiple widgets vs. shortcode:
- Widgets: More memory usage (all widgets load)
- Shortcode: More efficient (only one set loads)
- Recommendation: Use shortcode approach
Large catalogs:
- Consider pagination in filters
- Use lazy loading for attributes
- Implement server-side caching
Alternative Approaches
Using Multiple Shortcodes
Instead of one dynamic shortcode, use multiple static ones:
// On wheel category page [woof tax_only="pa_sub-type,pa_material,pa_colour,pa_size" ajax_redraw="1"] // On Lingerie category page [woof tax_only="pa_size,pa_colour,pa_material" ajax_redraw="1"] // On Shop page [woof tax_only="product_cat,pa_colour" by_price="1" ajax_redraw="1"]
Then use Widget Logic to show correct shortcode on each page.
Using Template Files
Add conditional logic directly in your theme template:
<?php
if (is_product_category('books')) {
echo do_shortcode('[woof tax_only="pa_sub-type,pa_material,pa_colour,pa_size"]');
} elseif (is_product_category('lingerie')) {
echo do_shortcode('[woof tax_only="pa_size,pa_colour,pa_material"]');
} elseif (is_shop()) {
echo do_shortcode('[woof tax_only="product_cat,pa_colour" by_price="1"]');
} else {
echo do_shortcode('[woof]');
}
?>
Summary
Problem: Same filters show everywhere, cluttering interface
Solution 1: Enable AJAX redraw for dependent filtering
Solution 2: Create [woof_dynamic] shortcode with category mapping
Solution 3: Add Shop page handling with minimal filters
Solution 4: Use Widget Logic for advanced visibility control
Best Approach: Combine Solutions 2 + 3 for comprehensive dynamic filtering
Key Code:
add_shortcode('woof_dynamic', function() {
// Shop page logic
if (is_shop() AND !is_product_category()) {
return do_shortcode('[woof tax_only="product_cat" by_price="1"]');
}
// Category mapping
$term = get_queried_object();
if ($term AND $term->taxonomy === 'product_cat') {
$filters_map = [
'category-slug' => ['pa_attribute1', 'pa_attribute2'],
];
// Return category-specific filters
}
return do_shortcode('[woof]'); // Fallback
});
This creates a professional, user-friendly filtering experience tailored to each product category.
Troubles? Ask for Support!
