apply_filters( 'relevanssi_pre_excerpt_content', string $post_content, object $post, string $query )
This filter hook filters the post content before Relevanssi generates an excerpt out of it.
Parameters
$post_content
(string) The post content.
$post
(object) The post object, usually a WP_Post object, but not always.
$query
(string) The search query.
More information
When Relevanssi generates an excerpt from a post, the post content goes through many filter hooks, and this hook is one of them. First comes relevanssi_post_to_excerpt
, which allows you to filter the whole post object. Then comes this filter hook, which lets you filter the post content before Relevanssi removes the shortcodes from the post content.
After this filter hook, the custom field content is added to the post content so that Relevanssi can use it in the excerpts, the_content
filters are applied, and the post content goes through the relevanssi_excerpt_content
filter hook. Then the excerpts are generated.
This filter hook is helpful if you need to modify the shortcodes on the page because this hook runs before Relevanssi removes the shortcodes.
Relevanssi uses this filter hook to remove unwanted page builder shortcodes. The function relevanssi_remove_page_builder_shortcodes
runs on this hook on priority 9, so if you need to do something with this filter hook that concerns the page builder shortcodes, you need to add your function on priority 8 or lower. (For more information on this, see relevanssi_page_builder_shortcodes
.)
Relevanssi also uses this filter hook to add attachment content to the post content used in the excerpts.