In my theme I want to display the featured image, but I also want to display the title attribute (of the image, not of the post/page) beside the image itself.
Is there a simple way to do this? Where should I be looking?
Thanks,
John.
In my theme I want to display the featured image, but I also want to display the title attribute (of the image, not of the post/page) beside the image itself.
Is there a simple way to do this? Where should I be looking?
Thanks,
John.
You must be logged in to post a comment.
post_excerpt is actually the caption attribute. Here is the correct answer:
Easy!
Taken from: http://www.billerickson.net/wordpress-featured-image-captions/
Since WordPress 4.6 there are new functions for the post thumbnail caption
Get caption text: (Doc link)
Output caption text: (Doc link)
You can add a specific post as object or id as parameter. Without (like shown above) WordPress uses the current post.
Try this code to get thumbnail title:
Don’t forget to add open and close PHP tag.