找到正在使用的主题的相关文件,找到:if (has_post_thumbnail())相关然后用以下代码调用
$post_thumbnail_url = get_post_thumbnail_url($post->ID);
在function.php中增加函数
//获取 WordPress 特色图片地址
function get_post_thumbnail_url($post_id){
$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
$thumbnail_id = get_post_thumbnail_id($post_id);
if($thumbnail_id ){
$thumb = wp_get_attachment_image_src($thumbnail_id, 'thumbnail');
return $thumb[0];
}else{
return false;
}
}