Display Media Caption with Featured Image
-
Me:
Searching for a way to retrieve a Featured Image’s caption for the front end.That is, my theme’s user:
- Uploads an image to the Media Library and defines that image’s Title (“Football”), Alternate Text, Caption, and Description (all on the Edit Media page).
- Creates a Page named “Toejam”
- Chooses “Set Featured Image” and selects that recently uploaded ‘Football’ image to “use as featured” in ‘full’ size.
- Expects to be finished with the work
I have sorted out how to display the Featured Images of every Page with a Featured Image as links to the respective Page’s permalinks. However, I am having great difficulty displaying each of those Featured Images’ Caption or Description as either an “alt” attribute in the HTML or preferably in it’s own <p> tag.
A link to an image from the Meda page:
imageI’ve been struggling to use:
featured-image-display-image-captionAn example of what I want on the front end:
<div> <a href="ex.amp.le"><img width="600" height="200" src="ex.amp.le/football.jpg" class="attachment-full wp-post-image" alt="Future Media Caption" title="Future Media Caption" /></a> <p>Future Media Caption</p> </div> <div> <a href="ex.amp.le"><img width="600" height="200" src="ex.amp.le/football.jpg" class="attachment-full wp-post-image" alt="Future Media Caption" title="Future Media Caption" /></a> <p>Future Media Caption</p> </div>You: Providing helpful suggestions.
Thank you!
The topic ‘Display Media Caption with Featured Image’ is closed to new replies.