Incorrect base product IDs

The incorrect base product IDs error occurs when the FiboFilters base products don’t match the products retrieved by the WooCommerce main query. One of the visible symptoms is that, after refreshing the page, products appear to be loaded via AJAX even though they should not be. This usually happens when a theme, plugin, or custom snippet modifies the main query (for example, by altering sorting).

This issue is currently automatically detected by a troubleshooting test in FiboFilters:

FiboFilters troubleshooting: incorrect base product IDs

What are base product IDs

Base product IDs represent the source data set used by FiboFilters to calculate available filters and product counters. They are available in the global JS variable called window.fiboFiltersData.base_products_ids. This list contains all product IDs that match the current archive.

The WooCommerce main query should always be consistent with base product IDs. The only difference is that the main query returns only the products for the current pagination page, while base product IDs contain the entire list of matching product IDs, ignoring pagination.

Common causes of mismatched product lists

  1. The theme or a plugin modifies the WooCommerce main query by removing or altering orderby, adding custom group_by logic or changing the query with posts_clauses or pre_get_posts. In such cases, FiboFilters and the main query may return different sets of products or return them in a different order.
  2. User snippets that rely on $query->is_main_query(). When a snippet modifies the query only when is_main_query() is true, the logic is applied to the main loop but not to the base product loop. As a result, the main query and base product IDs differ.

Solution

Make base product query behave like the main query

This can be done by applying the following code:

add_filter( 'fibofilters/request/base_product_ids/override_global_wp_query', '__return_true' );

Learn how to add this snippet to your WordPress.

This makes the base product loop temporarily act as the main query, allowing conditions such as $query->is_main_query() to apply consistently to both datasets.

Modify base product IDs directly

If you prefer to modify the base product IDs independently of the main query, you can use the following hook:

add_filter( 'fibofilters/request/base_product_ids', function( $ids ) {
	/* Your custom code to modify the base product IDs */
	return $ids;
} );

Learn how to add this snippet to your WordPress.