I am retrieving some images post with:
$img = wp_get_attachment_image_src( $attachment_id, 'full' );
How can I retrieve the image title?
Thanks.
I am retrieving some images post with:
$img = wp_get_attachment_image_src( $attachment_id, 'full' );
How can I retrieve the image title?
Thanks.
You must be logged in to post a comment.
In WordPress attachments are stored as posts so you can use most of the post specific WordPress calls and functions to read/write data associated with the attachment. This applies to post meta data for an attachment as well.
So in this case, since you have the post ID ( same as $attachment_id ) you can simply use the
get_the_title()
function:This returns a string of the post’s title for the given post ID.
See more info. at the codex docs here.