[woof_products_ids_prediction]
The [woof_products_ids_prediction] shortcode is a specialized wrapper around [woof_products] designed to predict which product IDs will match the current filter state. It is useful for AJAX-driven setups where you need to know the filtered product set before rendering.
How It Works
Internally, this shortcode calls the same woof_products() method with the is_prediction flag set to true. The only behavioral difference is that per_page defaults to 9999 in prediction mode — meaning it returns all matching products by default, which is useful for obtaining the full set of product IDs.
Attributes
Supports all attributes from [woof_products]:
| Attribute | Default | Description |
|---|---|---|
columns | WooCommerce default | Number of product columns |
orderby | no | Order by field (no = use WooCommerce settings, price, price-desc, date, title, etc.) |
order | no | Sort order (ASC, DESC, or no for default) |
page | 1 | Page number for pagination |
per_page | 9999* | Products per page. In prediction mode defaults to 9999 (all products). Use a specific number if you need paginated results. |
is_ajax | 0 | Enable AJAX mode (1 or 0) |
taxonomies | '' | Filter by taxonomies. Format: product_cat:9,12+locations:30,31 (plus sign separates different taxonomies) |
sid | '' | Search ID for identifying specific filter instances |
behavior | '' | Special behavior (e.g., recent for recent products) |
custom_tpl | '' | Path to a custom template file (e.g., wp-content/themes/my_theme/woo_tpl_1.php) |
tpl_index | '' | Index of any template extension |
predict_ids_and_continue | false | Predict IDs and continue with the full product query |
get_args_only | false | When true, returns only the WP_Query arguments without executing the query |
product_ids | '' | Comma-separated list of specific product IDs to display |
post__in | '' | Comma-separated list of post IDs to include |
display_on_search | 0 | Set to 1 to show products only when a search/filter is active |
* In prediction mode (woof_products_ids_prediction), per_page defaults to 9999. In the regular [woof_products] shortcode, it defaults to 0 (uses the plugin settings).
Basic Usage
[woof_products_ids_prediction]
Returns all product IDs matching the current filter state.
Usage with Taxonomies
[woof_products_ids_prediction taxonomies="product_cat:15,17" orderby="price" order="ASC"]
Returns IDs of products in categories 15 and 17, sorted by price ascending.
Usage with AJAX
[woof_products_ids_prediction is_ajax="1" per_page="12" display_on_search="1"]
Shows products in AJAX mode, 12 per page, only when a filter is active. In prediction mode, this helps preload the expected result set.
Getting Only Query Arguments
[woof_products_ids_prediction get_args_only="true"]
Returns only the WP_Query arguments as an array instead of executing the query — useful for advanced custom integrations where you want to inspect or modify the query before running it.
PHP / Hooks Integration
You can filter the products query using the standard WooCommerce and HUSKY hooks. For example, to modify the query arguments:
add_filter('woof_draw_products_get_args', function($args) {
// Modify query arguments before execution
$args['post_type'] = array('product', 'product_variation');
return $args;
});
When to Use woof_products_ids_prediction vs [woof_products]
- Use
[woof_products]when you want to display products with filtering. - Use
[woof_products_ids_prediction]when you need to predict which products will match — for example, to preload product data, update a counter, or prepare related queries before rendering. - The prediction mode defaults to fetching all matching products (per_page=9999), making it ideal for obtaining the complete set of product IDs.