Support » Plugin: Relevanssi - A Better Search » Search results showing short codes

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

    (@msaari)

    Adding this to your theme functions.php should do the trick:

    add_filter( 'relevanssi_page_builder_shortcodes', 'rlv_wp_show_posts' );
    function rlv_wp_show_posts( $shortcodes ) {
        $shortcodes[] = '/\[wp_show_.*?\]/';
        return $shortcodes;
    }

    Hi,
    Thank you for the quick reply

    Without effect.
    For adding to functions.php I use Code Snippets plugin. (https://wordpress.org/plugins/code-snippets/).
    I tried the following, without effect:
    add_filter( 'get_the_excerpt', 'strip_shortcodes', 20 );

    add_action( 'wp', function() {
        add_filter( 'get_the_excerpt', 'strip_shortcodes', 20 );
    } );
    add_filter( 'the_excerpt', function( $content ) {
        $content = strip_shortcodes( $content );
    
        return $content;
    } );
    Plugin Author Mikko Saari

    (@msaari)

    You can try to use relevanssi_excerpt. strip_shortcodes() may or may not work, because it only strips registered shortcodes, and it’s possible the the wp_show_posts shortcode is not registered at that point.

    Does this work?

    add_filter( 'relevanssi_excerpt', function( $content ) { return preg_replace( '/\[wp_show_.*?\]/', '', $content ); } );

    Hi
    The WP Show Posts plugin author has created a snippet that has worked.
    Now the shortcodes in search results aren’t showing as plain text.

    add_filter( 'get_the_excerpt', function( $content ) {
        $content = preg_replace( '#\[[^\]]+\]#', '', $content );
    
        return $content;
    } );

    Thanks for the help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.