根据the Codex entry for the_post_thumbnail()
, 可以将属性数组作为参数传递:
<?php the_post_thumbnail( $size, $attr ); ?>
所以您只需要定义数组;下面是Codex示例,修改后包括
title
属性:
$post_thumbnail_attr = array(
\'src\' => $src,
\'class\' => "attachment-$size",
\'alt\' => \'alt here\',
\'title\' => \'title here\',
);
。。。然后你可以传给
the_post_thumbnail()
:
the_post_thumbnail( \'large\', $post_thumbnail_attr );