I found this worked for me
您可以将页面的功能图像用作如下元素的背景图像-->
<?php $backgroundImg = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), \'full\' );?>
<article class="banner" style="background-image(url(\'<?php echo $backgroundImg[0]; ?>\'))"></article>
但我建议在“src”属性的image元素中使用它-->
<article class="banner">
<?php $backgroundImg = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), \'full\' );?>
<img src="<?php echo $backgroundImg[0]; ?>" alt="Feature Image">
</article>
并将图像大小设置为适合横幅元素的大小。