wordpress get gallery images title

I am retrieving some images post with:

$img = wp_get_attachment_image_src( $attachment_id, 'full' );

How can I retrieve the image title?

Read More

Thanks.

Related posts

Leave a Reply

1 comment

  1. 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:

    $sImageTitle = get_the_title( $attachment_id );
    

    This returns a string of the post’s title for the given post ID.

    See more info. at the codex docs here.