I use a theme that calls get_the_content()
to display short excerpts of the latest blog posts on the home page. Now I noticed that the excerpt sometimes starts with an image caption, if the blog post contains a picture at the very beginning. I usually do that and make the text float around it.
I always set the first three caption fields on an image (Alt Text, Title, Caption).
Is there any way to strip these image captions from the return value of get_the_content()
or is there any other method that I could possibly call instead? I checked the documentation, but there seems no argument to exclude images from the return value.
strip_tags()
andstrip_shortcodes()
are applied to the excerpt already, but the image caption is plain text. There is no CSS identifier either. Is there no alternative toget_the_content()
?$output = get_the_content();