[英]How to use get_post_meta to get thumbnail in wordpress
我有一个wordpress网站,我正在尝试获取帖子的缩略图(又称特色图片)。 我不能使用以下功能,因为由于布局原因我不在循环中。
the_post_thumbnail_url( )
我只是想知道是否可以通过此功能获取帖子的缩略图。
$thumb_1 = get_post_meta( '40', 'thumb', true ); //40 is the post_id
我几乎可以检索所有其他自定义字段,但是,检索thumb似乎不起作用。 有谁知道缩略图的“关键”是什么?
也许更好的方法是使用函数get_the_post_thumbnail_url(),该函数可让您传递帖子ID(并且无需循环:
https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/
所以$thumb = get_the_post_thumbnail_url(40);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.