如何使用帖子标题作为Wordpress中帖子特色图片的替代文字?
请告诉我如何/在哪里可以调整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.'" />