Output caption for featured image

Does anyone know how you output the caption of a featured image within a loop? I know how to do it for a custom image field (ie: ACF) but not how to do it for just the main featured image.

I’m sure it’s probably incredibly simple and I’m just being daft!

Searching for “featured image” in the documentation, I see there’s a field named image that gets the featued image as an attachment loop type. And looking at the available fields of an attachment, the field caption gets the caption.

Something like this:

<Loop field=image>
  <Field caption />
</Loop>

Maybe there’s a shortcut.

<Field caption field=image />

Mm, probably that won’t work - I think the field attribute of a Field tag tries to get the subfield. Then this might work:

<Field image field=caption />

Perfect, thank you - yes that works!

1 Like