Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #184973

    I added to my functions.php (in my child theme folder). This is my functions.php file contents:

    <?php
    
    /*
    * Add your own functions here. You can also copy some of the theme functions into this file. 
    * WordPress will use those functions instead of the original functions then.
    */
    function remove_shortcode_from_search($content) {
      if ( is_search() ) {
        $content = strip_shortcodes( $content );
      }
      return $content;
    }
    add_filter('the_content', 'remove_shortcode_from_search');

    It won’t remove my shortcodes from search results. What am i doing wrong?

    #185368

    Hi basilicon!

    What version of Enfold are you using?

    I think that behavior is already here /includes/loop-search.php (line 95):

    $excerpt = strip_shortcodes( get_the_content() );

    Cheers!
    Josue

    #185517

    I am using v 2.3.2

    Yes i see the code in there as you wrote. But this is what i get:

    search results with shortcodes

    There are shortcodes like: [/av_textblock] [av_textblock ] [social_share]

    If it matters. I am using pages only. Not posts.

    #185535

    Can i choose to only display excerpts from pages since the content is filled with shortcodes?

    #185537

    So i found and fixed this. I added excerpts to all pages. Then i untcked option: “Use custom excerpts centered on search term matches.” This was in “Search Relevance” plugin settings.
    search relevance plugin settings

    My bad.

    #185737

    Glad you figured it out :)

    Regards,
    
Josue

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘strip shortcodes in searchresults’ is closed to new replies.