For developers
woohoo_loop_total_posts
Filter the total post count used by the Ajax Query Count element and pagination.
apply_filters( 'woohoo_loop_total_posts', int $total_posts, WP_Query $loop, array $args );Parameters:
$total_posts
int
The computed total post count
$loop
WP_Query
The query object (post__in may have been modified by pre_get_posts)
$args
array
The original query arguments passed to WP_Query
Example — Variations as cards:
When your shop archive shows each WooCommerce variation as its own card, Woohoo counts parent products but your loop displays variations. This filter lets you return the correct count:
add_filter( 'woohoo_loop_total_posts', function( $total_posts, $loop, $args ) {
$post_type = $loop->get( 'post_type' );
if ( ! is_array( $post_type ) || ! in_array( 'product_variation', $post_type, true ) ) {
return $total_posts;
}
$post_in = $loop->get( 'post__in' );
if ( empty( $post_in ) || $post_in === [ 0 ] ) {
return $total_posts;
}
return count( $post_in );
}, 10, 3 );woohoo_facet_term_counts
Filter facet term counts before they are displayed. Runs after counts are computed and formatted, but before exclusions and ordering.
Parameters:
$result
array
Array of term data, each with slug, name, count, etc.
$target_slug
string
The facet slug (e.g. "serie")
$target_tax
string
The taxonomy name (e.g. "product_cat", "pa_colore")
$base_ids
array
Post IDs currently in the filtered result set
$is_product_attribute
bool
true for WooCommerce product attributes (pa_*), false for regular taxonomies
Example — Multiply taxonomy counts by variation count:
When showing variations as cards, taxonomy facets (Category, Serie) count parent products. But your shop displays N cards per product (one per variation). This filter multiplies the count:
woohoo_filters/indexer/get_rows
Filter the index rows before they are inserted into the Woohoo index table. Use this to add extra rows for data that Woohoo doesn't index by default.
Example — Index variation attributes on the parent product:
WooCommerce stores attributes like pa_colore on variations, not on the parent product. Without this, the Color facet returns no results for variable products:
Last updated