In regards to my previous question about shortcode captions, it doesn’t appear to me that the actual text of a caption is stored anywhere other than in the post content within the shortcode itself.
I would have thought that wp_get_attachment_metadata
would store the info for an attachment, but it doesn’t.
Am I wrong? Or does WordPress not store the actual caption anywhere?
Yes, it stores the caption in it’s own place in the DB. I can’t quote the exact location but in WordPress, “Attachments” are a post type and it stores each attachment just like a post. For an attachment post type, it treats the Image Caption as
the_excerpt
the Image Description asthe_content
and the Image Title as…the_title
.where
$post_id
is the current post, this code will output all the attachments of a post, and their titles descriptions and captionsAttachments are all children of the post they are attached to, and you can use this to do your own custom gallery code. They also have a lot of data in their custom fields, such as image dimensions, EXIF data, etc They can even be commented on.
You can take the code from the inner loop and place it in attachment.php in your theme, just double check I haven’t made any syntax typos before you do.