找到正在使用的主题的相关文件,找到: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;
}
}
- 本文固定链接: https://freekk.cn/4244.html
- 转载请注明: 漱石 于 最后的面包 发表
捐 赠如果您觉得这篇文章有用处,请支持作者!鼓励作者写出更好更多的文章!