I'm trying to get the captions from images in Wordpress but I can't find an easy function to grab this bit of information.
Anyone know a way to get this?
Thanks
I'm trying to get the captions from images in Wordpress but I can't find an easy function to grab this bit of information.
Anyone know a way to get this?
Thanks
I'm using this code, It works fine.
Turns out captions are stored as post excerpts. So,
will print out the caption if you are on the attachment image page (image.php in your theme) and inside the Loop.
Using Wordpress 4.8, this little guy worked for me:
Put this inside figure tag of your single.php file
If you are trying to get the caption while in a post you can echo it out inside your "the_post_thumbnail" tag.
You can also use the same method to show the image description. This is a little better feature in WordPress 3.5
If you need to style the caption or description you can wrap it in a div like below.
Hope that helps.