I’ve got a strange issue with image captions. Adding an image within a paragraph where the text is wrapped around the image works OK. The issue is adding an image with a caption; a closing </p> tag is added right before the <figure, and as a result, the text wrapping and font size is broken. No <p> tag is added after the </figure> tag. There are orphaned </p> tags at the end of the paragraph.
This is using the classic editor and not Gutenberg. I’ve looked in theme functions in Sage Starter and don’t see anything that would impact WordPress autop, or strips <p> tags from images, etc.
Any ideas?
From Dev Tools:
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p><figure id="attachment_2239" aria-describedby="caption-attachment-2239" style="width: 300px" class="wp-caption alignleft"><img src="example.com/wp-content/uploads/2018/10/kitten-300x262.jpg" alt="image" width="300" height="262" class="size-medium wp-image-2239" /><figcaption id="caption-attachment-2239" class="wp-caption-text">A little kitten captionlaborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> </p> </p>
Thanks, adding images with captions via the Media Library works fine in other themes. The above markup resulted in inserting from the Media Library in Sage, so something somewhere is adding that p tag. I did have to add the CSS for the WordPress standard alignleft, etc., image alignment to the site stylesheet, so text would wrap around images. That’s when I discovered captions were broken. This is a site I inherited; is it possible some theme functions weren’t originally compiled in the theme? I’m a beginner with Sage and composer, etc.
Good point; I should have checked the Trac. Seems like that or a similar bug has reappeared in some cases, even with WP 5.2, twentynineteen and no plugins.