Support » Plugin: Relevanssi - A Better Search » Search shows shortcodes in resultpage

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Mikko Saari


    Which short codes?

    Short codes from visual composer. for instance this result

    …;1/3″][vc_column_text] Just like the symptoms of HAE, each pregnancy experience is variable. The good news is that today…

    Plugin Author Mikko Saari


    add_filter('relevanssi_excerpt_content', 'rlv_strip_shortcodes');
    function rlv_strip_shortcodes($excerpt) {
        return strip_shortcodes($excerpt);

    Add this to theme functions.php, and it should make all shortcodes disappear from excerpts.

    Thank you for a nice plugin! I also dislike showing shortcodes in search results. I’m also using a “visual page builder” in this case Divi Builder from Elegant Themes. While the short snippet fixes the problem, I’d really like to know, if there isn’t a better way to achieve this, than editing functions.php (childtheme or not).

    Would it be possible to add as an feature to Relevanssi?
    [x] Strip shortcodes from search-results

    Best regards

    Plugin Author Mikko Saari


    Here’s a Divi-specific solution.

    But yes, making this an option (or even silently the default setting actually, now that I think of it) makes sense.

    Great Mikko!

    The Divi-specific solution, ended up working best for me.

    I found this little gem for adding code snippets without editing theme files:

    An acceptable solution for me – but a built in option, sure would be even better 🙂

    Best regards



    @msaari, none of these suggestions are working for me. Trying to remove Visual Composer shortcodes from my search results.

    Do you have any other suggestions?

    Plugin Author Mikko Saari


    Christine, please start a new thread for your problem and please explain your problem in a bit more detail. What shortcodes are you trying to remove exactly and what have you done so far?

    I only see updates to the new threads, so I can’t follow a discussion in an old thread like this.



    I am also seeing shortcodes in search results. I tried the relevanssi_excerpt_content + strip_shortcodes solution above, but it didn’t work. I think this is because strip_shortcodes only works on properly formed shortcodes, but because the excerpt only takes part of the text, it is only including the opening VC shortcode section which would normally be “[VC…]lorem ipsum dolor sit amet[/VC…]” but in the excerpt is just “[VC…]lorem ipsum dolor”. I used
    preg_replace('~\\[[^]]*\\]~', '', $excerpt);
    instead, but I think this is still probably not sufficient in the general case, as I rather think any spaces in the shortcode might be where the excerpt stops excerpting so you end up seeing half a short code. For example, say “[VC…]lorem ipsum dolor sit amet[/VC param=’xxx’]”, you might get “[VC…]lorem ipsum dolor sit amet[/VC” as the excerpt and therefore “lorem ipsum dolor sit amet[/VC” after filtering.

    I really think you need to deal with this inside the plugin, as the filter content doesn’t have complete-enough information. (I’m not sure what would happen with VC and an ordinary excerpt – I assume WP deals with shortcodes in a general way in this situation, which relevanssi isn’t doing.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Search shows shortcodes in resultpage’ is closed to new replies.