apply_filters( 'relevanssi_post_content_after_shortcodes', string $content, object $post_object )
Filters the post contents in indexing after shortcodes are expanded but before the HTML tags are removed.
Parameters
$content
(string) The post content.
$post_object
(object) The full post object, usually a WP_Post object.
More information
As Relevanssi indexes the post content, the post content is passed through a multi-step process. First the post content passes through relevanssi_post_content
, then more content may be added with relevanssi_content_to_index
, then the shortcodes are either expanded or removed, depending on the settings, and then the content passes through this filter hook.
After this filter hook, the invisible elements (<script>
, <style>
, <embed>
, <object>
, <applet>
, <noscript>
, <iframe>
, <noembed>
and <del>
tags) are removed, internal links are processed, and all HTML tags are stripped. After that the content passes through relevanssi_post_content_before_tokenize
, then it’s tokenized and passed through relevanssi_indexing_tokens
.
If you want to modify the post content somehow, there are many points in the process where to enter. In general relevanssi_post_content
is the logical option, but if you specifically want to modify the content generated by a shortcode, this filter hook is the right spot.
add_filter( 'relevanssi_post_content_after_shortcodes', 'rlv_modify_content', 10, 2 ); function rlv_modify_content( $content, $post ) { if ( 'Post to Modify' === $post->post_title ) { $content = str_replace( 'dog', 'cat', $content ); } return $content; }