Skip to content

Filter: bricks/filter_element/count_source_{filter_source}

Filters indexed count data for a specific custom filter source. The {$filter_source} portion of the hook name should be replaced with the actual filterSource key, such as wcField or a custom source.

Built-in taxonomy, wpField, and customField sources are handled before this dynamic filter runs.

  • $count_source (array): Indexed count rows. Each row can include filter_value, filter_value_display, filter_value_id, filter_value_parent, and count.
  • $element (object): The filter element instance.
add_filter( 'bricks/filter_element/count_source_wcField', function( $count_source, $element ) {
foreach ( $count_source as &$row ) {
if ( isset( $row['filter_value'] ) && $row['filter_value'] === 'featured' ) {
$row['count'] = 999;
}
}
unset( $row );
return $count_source;
}, 10, 2 );