relevanssi_post_to_index

apply_filters( 'relevanssi_post_to_index', WP_Post $post, object $object )

This filter hook filters the post object before Relevanssi indexes it.

Parameters

$post
(WP_Post) The post object. This object may also be a standard class that looks like a WP_Post object.

$object
(object) When indexing posts, this is the same post object again. When Relevanssi indexes taxonomy terms, this is the term object, and when Relevanssi indexes post type archives, this is the post type object.

More information

When Relevanssi indexes a post, Relevanssi first checks if the post is hidden, and if it is, it is not indexed. Then Relevanssi checks the post with the relevanssi_do_not_index filter hook to see if it is blocked.

If the post passes these checks, it will then go through this filter hook. This filter hook gives you a chance to modify the post object before Relevanssi processes it, and you can do whatever you want with it.

If you want to modify the content, that may be easier with the relevanssi_content_to_index filter hook, which gives you the content as a string. For titles, there’s relevanssi_post_title_before_tokenize.

You can use this same filter hook to modify the taxonomy terms when Relevanssi Premium indexes taxonomy terms. You can also use relevanssi_tax_term_additional_content to change the taxonomy term description.

Post type archive indexing also uses this filter hook, but you can also use relevanssi_post_type_additional_content to modify the post type archive description.