If the results on your search page look bloated, it’s probably because of some shorttags or tags not beeing removed. The script fixes this issue.
The first line removes everything between square brackets (shortcodes) and the second one strip tags.
function my_search_filter($post) { if (is_search()) { $post->post_content = preg_replace("/\[(.*?)\]/i", '', $post->post_content); $post->post_content = strip_tags($post->post_content); } } // Add filter to the_content add_filter('the_post', 'my_search_filter', 0); |