Archived topic
adding an image's caption below a post's featured image
7 replies · Started by Allen on February 19, 2022
What is the easiest way to have the caption appear below a feature image on a single post? Thanks!
Hi Allen,
The easiest way would be using a plugin, this article explained how:
https://www.wpbeginner.com/wp-tutorials/how-to-display-wordpress-post-thumbnails-with-captions/
The not so easy way that you can try is this solution David provided here :)
https://generatepress.com/forums/topic/cant-display-featured-image-captions/#post-854633
The primary reason I chose Generate Press was to keep the code super light. If I have to add plugins to get basic functionality, that benefit gets lost.
Tossing snippets in is reasonable.
I found this post in the forum before posting my question, but wasn't sure about it. The code looks different/cleaner from #2 above:
https://generatepress.com/forums/topic/add-featured-image-caption-via-elements/#post-1757071
Do you know if these two bring the same result? Guess I could test them both...
Just tested https://generatepress.com/forums/topic/add-featured-image-caption-via-elements/#post-1757071
Worked well, but for me the css had to be .wp-caption (no .featured-image in front).
Glad it works.
I have added the referenced PHP code snippet and CSS to add captions to all of my featured images. Works great! However, I am having one very minor issue. On my Archives home page, there is padding between the featured image and caption text. However, for the individual posts, there is no padding between the featured image and caption text.
You can see this at my site.
Is there an easy way to add the padding for individual posts? If not, I can live with how it works now.
Never mind. I found my issue in my Simple CSS snippet. I was trying to add a comment with "//". I deleted my "comment" lines, and now it's working correctly.
Glad to hear :)