i use this code to show post’s thumbnail in my site but this code cant show the title Attribute of the thumbnails.

how can i add Title Attribute to WordPress thumbnails?

<?php if ( has_post_thumbnail() ) {
the_post_thumbnail('large'); 
 } else {?>
<img alt="<?php the_title(); ?>" title="<?php the_title(); ?>" src="https://wordpress.stackexchange.com/questions/120527/<?php bloginfo("template_url'); ?>/img/thumbnail.png"/>
<?php }?>

you can see my site with this url : http://rokesh.ir

2 s
2

You can do that because you can add all the attributes you need:

the_post_thumbnail( 'large', array( 'title' => get_the_title() ) ); 

Please read on in the Function Reference of the_post_thumbnail.

Leave a Reply

Your email address will not be published. Required fields are marked *