WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can get the image to appear fine in this bit of gallery code. However the flex slider gets its caption from a <p> tag (class="flex-caption") and I just need to echo out the image title inside that paragraph.

<?php if (!empty($flex_gallery)) {?>                    
    <div class="flex-container resize-620">
        <div class="flexslider">
            <ul class="slides">     
                foreach ($flex_gallery as $att) {
                    echo ( '<li>' . wp_get_attachment_image( $att , 'blog-full-width' ).
                    <p class="flex-caption">' . I NEED JUST THE IMAGE TITLE HERE . '</p>'); 
<?php } else { ?>       
    <?php the_post_thumbnail(
        array('class' => 'featured-full-width-top'));
<?php } ?>
share|improve this question
up vote 1 down vote accepted

You should be able to get the image title with wp_get_attachment_metadata(). It will return an array that contains useful stuff like the width and height, as well as the title.

share|improve this answer
Thanks, from looking at that I can see that it should work. However I was stuck for time so I wrote a quick jQuery hack to transfer the title from the image to the paragraph. – john joe Mar 5 '12 at 12:53

you should be able to get it using get_post_title($att)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.