We're merging with GenerateBlocks! Learn more here.

[Resolved] Hide sortcode from search results

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Hide sortcode from search results

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #9606
    Rolandas
    Participant

    Hi
    I use GP Premium, WP Show Posts Pro and I replace native WordPress Search with
    Relevanssi searh plugin (https://www.relevanssi.com/).
    The problem:
    WP Show Posts Pro sortcodes placed on pages, appears (displayed) as text in search results.
    Question:
    Is it possible to add same CSS class to WPSP sortcodes, to be hiden as text in search results?
    Or possible use another method?

    #9610
    Rolandas
    Participant
    #9615
    Tom
    Keymaster

    Hi there,

    Try this PHP:

    add_filter( 'get_the_excerpt', 'strip_shortcodes', 20 );

    Let me know 🙂

    #9616
    Rolandas
    Participant

    Hi,
    without success

    #9636
    Tom
    Keymaster

    Hmm, what about this?:

    add_action( 'wp', function() {
        add_filter( 'get_the_excerpt', 'strip_shortcodes', 20 );
    } );
    #9640
    Rolandas
    Participant

    Hi,
    also unsuccessful

    #9725
    Tom
    Keymaster

    What about this?:

    add_filter( 'the_excerpt', function( $content ) {
        $content = strip_shortcodes( $content );
    
        return $content;
    } );
    #9740
    Rolandas
    Participant

    It doesn’t work either

    #9759
    Tom
    Keymaster

    Hmm, not sure what’s happening, then.

    Would you prefer the list to actually show up, or disappear completely?

    #9766
    Rolandas
    Participant

    I only would like that shortcodes of WSPS lists would not appear in search results.
    Now the shortcodes in search results are showing as plain text (https://www.sisla.lt/?s=pradzia or https://www.sisla.lt/?s=atlyginimo)

    #9777
    Tom
    Keymaster

    Let’s try manually removing it:

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

    Super! Works! Thank you very much

    #9807
    Tom
    Keymaster

    You’re welcome 🙂

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