• Hi I’m using the following to retrieve the post featured image

    I was just wondering how I’d display the article title as the image title, as at the moment a site I’m working on has hundreds of articles which all have random number titles such as “4546-46464”

    I know the tag the_title will retrieve the article title but I’m not sure how to insert it into this tag

    <?php the_post_thumbnail('large', 'title='); ?>

    This for a jquery plugin which is why I’m using the title tag.

    Cheers for any help

Viewing 2 replies - 1 through 2 (of 2 total)
  • The Codex Exemplifies this:

    $attr = array(
    		'src'	=> $src,
    		'class'	=> "attachment-$size",
    		'alt'	=> trim(strip_tags( $attachment->post_excerpt )),
    		'title'	=> trim(strip_tags( $attachment->post_title )),
    		);
    
    <?php the_post_thumbnail( $size, $attr ); ?>

    so, you could try this:
    <?php the_post_thumbnail('large', 'title='.trim(strip_tags( $attachment->post_title ))); ?>

    This worked perfectly for me. I now have a thumbnail image whose title reflects the associated post.

    Another way to do this would be to create an image tag and put the post thumbnail’s url into the image’s src attribute and the post title into the image’s title attribute.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘the_post_thumbnail title’ is closed to new replies.