Taxonomy Filter Block Hook Reference

The taxonomy filter block plugin can be customized with WordPress action and filter hooks for your specific needs.

rudr_tfb_get_terms_hide_empty

This filter hook allows you to decide whether you want to display taxonomy terms without any posts in your filters or not. The hook applies in both the Block Editor and on your site pages.

$hide_empty = apply_filters( 'rudr_tfb_get_terms_hide_empty', $hide_empty );
$hide_emptybool
By default – true (items without posts will be hidden).

Why this filter hook is not a part of block settings?

Because it is quite specific to certain user requirements, and usually not needed for most of the sites, and our goal is to keep the block settings as simple as possible.

Example. Display terms without any posts in taxonomy filters

add_filter( 'rudr_tfb_get_terms_hide_empty', function( $hide_empty ) {
	$hide_empty = false; // do not hide
	return $hide_empty;
} )

Just add this code snippet to your website and that’s pretty much it.

There is also a simplified one-line version of this code snippet:

add_filter( 'rudr_tfb_get_terms_hide_empty', '__return_false' );

rudr_tfb_get_terms_exclude

This filter hook allows you to completely exclude specific terms from the filter. It will be applied both in the block editor and on your site pages.

$exclude = apply_filters( 'rudr_tfb_get_terms_exclude', $exclude );
$excludeint[]
Provide a list of term IDs which you’d like to completely exclude from the filters.

Example. Exclude a specific term by its ID from taxonomy filters

add_filter( 'rudr_tfb_get_terms_exclude', function( $exclude ) {
	// exclude a term with ID = 5 (of any taxonomy)
	$exclude[] = 5; 
	// exclude a term with ID = 71
	$exclude[] = 71;

	return $exclude;
} )

Please check this guide if you don’t know where to insert this code snippet.

Need more help?