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?
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
I am using v 2.3.2
Yes i see the code in there as you wrote. But this is what i get:
There are shortcodes like: [/av_textblock] [av_textblock ] [social_share]
If it matters. I am using pages only. Not posts.
Can i choose to only display excerpts from pages since the content is filled with shortcodes?
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.
My bad.
Glad you figured it out :)
Regards,
Josue