HUSKY - WooCommerce Products Filter Professional

How to Fix Pagination Showing Too Many Pages with WOOF Filtering

If your WooCommerce pagination displays incorrect page numbers when using WOOF (HUSKY) product filters, this guide will fix it.

The Problem

Symptom: When filtering products with WOOF/HUSKY, pagination shows more pages than actually exist.

Example:

  • Filter shows 15 products (should be 2 pages)
  • Pagination displays: 1, 2, 3, 4, 5… (5+ pages)
  • Clicking page 3+ shows empty results or “No products found”

What’s happening: WooCommerce’s pagination is calculating page count based on the total product catalog, not the filtered results. WOOF filters the products, but pagination doesn’t update accordingly.

The Solution

Add this code to force pagination to use the correct page count from WOOF’s filtered query.

Step 1: Add Code

Add this to your child theme’s functions.php:

/**
 * Fix pagination page count when using WOOF filtering
 * Forces pagination to use correct max_num_pages from filtered query
 */
add_filter('woocommerce_pagination_args', function($args) {
    global $wp_query, $WOOF;
    
    // Check if WOOF filtering is active
    if ($WOOF->is_isset_in_request_data($WOOF->get_swoof_search_slug())) {
        // Force correct page count from HUSKY filtered query
        $args['total'] = $wp_query->max_num_pages;
    }
    
    return $args;
}, 999);

Priority 999: Ensures this runs after other pagination modifications.

Step 2: Clear Cache

  1. Clear WordPress cache (if using cache plugin)
  2. Clear browser cache (Ctrl+F5)
  3. Test filtered results

Step 3: Verify

  1. Apply any WOOF filter (category, price, attributes)
  2. Check pagination at bottom of page
  3. Page numbers should now match actual filtered results

Before fix:

Showing 12 products Pages: 1 2 3 4 5 6 7 8 (wrong!)

After fix:

Showing 12 products Pages: 1 2 (correct!)

How It Works

if ($WOOF->is_isset_in_request_data($WOOF->get_swoof_search_slug())) {

What this does: Checks if WOOF filtering is currently active by looking for WOOF’s search parameter in the URL.

$args['total'] = $wp_query->max_num_pages;

What this does: Overrides WooCommerce’s pagination total with the actual page count from the filtered WordPress query.

Why priority 999? Some themes or plugins modify pagination. Priority 999 ensures this code runs last and takes precedence.

 

Troubleshooting

Pagination Still Wrong

Problem: Page count still incorrect after adding code

Possible causes:

  1. Code not in child theme
    • Verify you’re editing child theme’s functions.php
    • Parent theme updates will erase code if not in child theme
  2. Cache not cleared
    • Clear WordPress cache plugin
    • Clear server cache (hosting panel)
    • Test in incognito mode
  3. Theme overriding pagination
    • Some themes use custom pagination functions
    • Try increasing priority to 9999
    • Check theme documentation

Solution: Increase priority if theme conflicts:

add_filter('woocommerce_pagination_args', function($args) {
    // ... code ...
}, 9999); // Higher priority

 

When This Fix is Needed

You need this fix if:

  • ✅ Using WOOF/HUSKY for product filtering
  • ✅ Pagination shows more pages than exist
  • ✅ Clicking high page numbers shows no products
  • ✅ Filtered results count doesn’t match pagination

 


Troubles? Ask for Support!