Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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">     
            <?php
                foreach ($flex_gallery as $att) {
                    echo ( '<li>' . wp_get_attachment_image( $att , 'blog-full-width' ).
                    '</li>
                    <p class="flex-caption">' . I NEED JUST THE IMAGE TITLE HERE . '</p>'); 
                }
            ?>
            </ul>
        </div>
    </div>              
<?php } else { ?>       
    <?php the_post_thumbnail(
        'blog-full-width',
        array('class' => 'featured-full-width-top'));
    ?>      
<?php } ?>
share|improve this question

2 Answers 2

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

 
discard

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.