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 am using a code to call WP thumbnails and want to add a title="" tag. I would like the title to call the_title... how do I do so? I want to assign the title tribute to the image, not the link.

My code:

<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thmb-archive' ); } ?>
share|improve this question

1 Answer 1

up vote 2 down vote accepted

Use the arguments available for the_post_thumbnail() function as written in the codex.

Edit: just did a test with this and it worked for me:

$post_title = the_title( '', '', false);//get the title
$attr = array('title' => $post_title);//set the parameter 
the_post_thumbnail('full', $attr);//call the function
share|improve this answer
    
Tried it, but I'm trying to assign the title attribute to the image, not the link. –  AndrettiMilas Aug 2 '11 at 21:19
    
Edited my answer, give a look and let me know. –  kevin Aug 2 '11 at 21:29
    
I don't believe this works correctly, when done correctly it should assign the title to the image. –  AndrettiMilas Aug 2 '11 at 21:35
    
Yes, to the thumbnail actually, i just tested on a project i'm on with this exact function. –  kevin Aug 2 '11 at 21:42
    
themeforward.com/demo2/templates/archive When no image is assigned a title is in place of the image. However, the code above does not do the same. –  AndrettiMilas Aug 2 '11 at 21:52

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.