wordpress获取文章特色图像ID函数get_post_thumbnail_id()
The get_post_thumbnail_id()
Here's how you can use get_post_thumbnail_id()
:
<?php
$post_id = 123; // Replace with the actual post ID
// Get the featured image ID for the post
$thumbnail_id = get_post_thumbnail_id($post_id);
// Check if a featured image is set for the post
if ($thumbnail_id) {
echo 'The featured image ID for post ' . $post_id . ' is: ' . $thumbnail_id;
} else {
echo 'No featured image set for post ' . $post_id;
}
?>
Replace 123
with the actual post ID for which you want to retrieve the featured image ID. If the post has a featured image, get_post_thumbnail_id()
will return the ID of that image. If there's no featured image set for the post, it will return null
.
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
仍然有问题? 我们要如何帮助您?