relevanssi_hide_empty_terms

apply_filters( 'relevanssi_hide_empty_terms', bool $hide )

Filters whether empty terms are indexed or not when Relevanssi Premium indexes taxonomy terms.

Parameters

$hide
(bool) If true, empty terms are not indexed. Default true.

More information

Relevanssi Premium can index taxonomy terms independently of posts. By default, Relevanssi Premium will not include in the index taxonomy terms that are empty, that is not assigned to any posts. If you want to include empty terms in the search results, just make this filter hook return false and rebuild the index.

add_filter( 'relevanssi_hide_empty_terms', '__return_false' );

Relevanssi uses a MySQL query to get the terms:

SELECT t.term_id FROM wp_terms AS t, wp_term_taxonomy AS tt
WHERE t.term_id = tt.term_id AND tt.taxonomy = 'taxonomy'

If the empty terms are excluded, the query looks like this:

SELECT t.term_id FROM wp_terms AS t, wp_term_taxonomy AS tt
WHERE t.term_id = tt.term_id AND tt.count > 0 AND tt.taxonomy = 'taxonomy'