apply_filters( 'relevanssi_post_title_before_tokenize', string $title, WP_Post $post )

This hook filters the post title before Relevanssi tokenizes and indexes it.


(string) The post title.

(WP_Post) The post object. (Technically, this may sometimes be just a generic object that looks like a WP_Post object.)

More information

When Relevanssi indexes the post title in the relevanssi_index_title() function, first, Relevanssi applies the_title filters on it. Then the title goes through this filter hook. After that, Relevanssi tokenizes it with relevanssi_tokenize(), which means the title is split into individual words, removing stopwords and other non-word content (if you want to include stopwords in titles, there’s the relevanssi_remove_stopwords_in_titles filter hook for adjusting that).

Relevanssi filters the tokens with relevanssi_indexing_tokens, and finally, the function returns the tokens to the general indexing process.

Relevanssi uses this filter hook internally for pinning purposes. The pinning keywords are added to the post content to make sure they’re indexed if they don’t appear anywhere in the post. That’s fine, except when the post content is not indexed. Relevanssi uses this filter hook to add the pinned keywords to the title if that’s the case.

More examples: