Hello - I have a custom wordpress website and our news page contains a list of all our 'posts' by way of teaser text (approx the first 20 words).
Some of these posts contain images with captions - however the caption code appears in the teaser text on the main news page!
I have spent several hours trying to find a way to remove these - but none seem to work.
The closest I got was
add_filter('the_content', 'strip_shortcodes');
function remove_shortcode_from_index($content) {
if ( is_search() ) {
$content = strip_shortcodes( $content );
}
return $content;
}
But this only works on the posts, not on the main news index. And even then it removes the entire image rather than just the caption.