您可以在您的功能中执行此操作。php
update_post_meta($post_id, \'_thumbnail_id\', $thumbnail_id);
您还可以创建一个函数来实现这一点,将其作为“main”帖子的自定义字段。
function setSameThumbnails($post_id) {
// I assume that your custom field will be something like "31,64,43" for posts ids
$posts = get_post_meta($post_id, \'same_thumbnail\', true);
if($posts)
{
$posts = explode($posts, \',\');
if(is_array($posts))
{
foreach($posts as $post)
{
update_post_meta($post, \'_thumbnail_id\', get_post_thumbnail_id($post_id));
}
}
}
}
add_action(\'save_post\', \'setSameThumbnails\');