relevanssi_term_add_data

apply_filters( 'relevanssi_term_add_data', WP_Term $term, string $taxonomy )

This filter hook lets you modify taxonomy term objects before they are indexed.

Parameters

$term
(WP_Term) The term object.

$taxonomy
(string) The term taxonomy.

More information

When Relevanssi Premium indexes a taxonomy term, the first thing it does is pass the term object through the filters in this hook. Here you can modify the term object: add data, as the name suggests, and alter and delete the existing content. Note that Relevanssi only indexes the term name and description. Anything else Relevanssi ignores, so whatever you want Relevanssi to index needs to go to the term name or description.

There’s some overlap between this hook and relevanssi_post_to_index. When handling terms, this hook is better, but if you’re doing something that applies to posts as well, you may be able to do it with just one function on the relevanssi_post_to_index hook.

If you want to add content to the term, you can also use relevanssi_tax_term_additional_content.

Currently, Relevanssi only applies this filter hook in bulk indexing. When an individual term is indexed, Relevanssi doesn’t use this filter hook. That’s silly, and thus in the next version of Relevanssi, this filter hook is moved inside the individual term indexing.