您可以使用该功能set_post_thubmnail()
.
插入帖子后,只需调用此帖子,就可以开始了。
$yourpostid = wp_insert_post( $args ); // Define the post in the args first
set_post_thumbnail( $yourpostid, $thumbnail_id ); // set the ID of your thumbnail to be the featured image of your newly created post.