get_post_thumbnail_id()
get_post_thumbnail_id( int|WP_Post $post = null )
检索文章缩略图ID。
Retrieve post thumbnail ID.
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$post | (int | WP_Post) | 可选 | Post ID或WP_Post对象。默认值为全局$post。 |
返回(Return)
(int|string)发布缩略图ID或空string(int|string)。
源码(Source)
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
4.4.0 | wp-includes/post-thumbnail-template.php:50 | 16 | 2 |
笔记(Notes)
显示当前文章的所有附件,除了特色图片
注意,返回值通常是字符串,而不是整数(还没有看到函数返回整数)。
要设置文章缩略图,请使用“设置文章缩略图”:
get_post_thumbnail_id() 为WP2原创文章,链接:https://www.wp2.cn/functions/get_post_thumbnail_id/