如何使用帖子标题作为Wordpress中帖子特色图像的alt文本?
请告诉我如何/在哪里可以调整WordPress核心文件来实现这一点,因为似乎我现在使用的主题对重写图像的alt标签的插件没有任何反应…
谢谢!
无需更改WordPress核心文件:)
找到使用the_post_thumbnail()
函数的主题并将其更改为:
$title=get_the_title();
the_post_thumbnail( array(150, 150),array( 'alt' =>$title) );
user850010
你完全正确。
$title=get_the_title();
the_post_thumbnail( array(150, 150),array( 'alt' =>$title) );
这个很有用,Alex,请查看一下。
Alex,如果你想只显示特定的图像,那么使用下面的代码
<img src="'.wp_get_attachment_url( get_post_thumbnail_id($item->ID)).'" alt="'.$item->post_title.'" title="'.$item->post_title.'" />