.brx-option-count for "All" option

Hey there!

Please add also a count to the “All” option in filters. It would be fine, if you accept the dynamic tag there and render it in a but unfortunately, it doesn’t render out at all:

This should be easy to implement, right? :slight_smile:

1 Like

For anyone who want’s this I found a workaround using the “bricks/frontend/render_element” filter and the bricks_rendert_dynamic_data function.

add_filter( 'bricks/frontend/render_element', function( $html, $element ) {
    if (
        bricks_is_builder_main() ||
        bricks_is_builder_iframe() ||
        bricks_is_builder_call()
    ) {
        return $html;
    }

	if ( $element->name === 'filter-radio' && $element->id === 'BRICKSID' ) {
	
	    $filter_query_id = 'QUERYID';
	
	    $count_html = bricks_render_dynamic_data(
	        '{query_results_count_filter:' . $filter_query_id . '}'
	    );
	
	    $html = preg_replace(
	        '/(<li[^>]*brx-option-all[^>]*>.*?<span[^>]*brx-option-text[^>]*>)(.*?)(<\/span>)/s',
	        '$1$2' . $count_html . '$3',
	        $html,
	        1
	    );
	}
    return $html;
}, 10, 2 );

Just replace BRICKSID and QUERYID in the code and it should work.