• How can we use a caption for an image in a post created via the REST API?

    My current process is as follows:
    – Upload the image(s)
    – Set the metadata for the image (alt, caption etc)
    – Create a new post

    However, the caption isn’t present in the post, and adding [caption] tags inside the post html doesn’t work.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The [caption] shortcode should work as custom HTML, but I’ve had trouble using it without any attributes. With the attributes suggested on the caption shortcode doc page it does work for me.

    You do have to specify your caption in post content, it doesn’t automatically come from the caption meta field of the attachment.

    Instead of the shortcode, you could use normal HTML figure syntax, basically:
    <figure><img src="foo.jpg" /><figcaption>Example Caption</figcaption></figure>

Viewing 1 replies (of 1 total)
  • The topic ‘REST API Image Captions’ is closed to new replies.