Skip to content
Advertisement

WordPress get attachment image caption

I tried to get attachment meta caption value as mentioned here, but couldn`t get any output. Other meta arrays like [created_timestamp] or [iso] gave their values.

JavaScript

This issue happens to both and [title]. Any help is much appreciated.

Advertisement

Answer

The caption and title you are looking to get from wp_get_attachment_metadata are not the title and caption you add in WordPress they are meta data from the actual image itself. To get the WordPress data use something like this (assuming $id is the id of your image).

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement