这是我试图将特色图片网址设置为BG的代码。它对page.php工作正常。但是在Woocommerce Shop(post-type-archive-product)页面中,它显示的是产品特色图像而不是页面特色图像。
任何解决方案
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?>
<header style="background-image: url('<?php echo $thumb['0']; ?>')" class="inner-page-header">
<div class="wrap">
<div class="page_header">
<?php the_title(); ?>
</div>
</div>
</header>
您可以使用wc_get_page_id()
获取页面ID并使用它来获取图像源。这应该工作。
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( wc_get_page_id( 'shop' ) ), 'full' );?>
<header style="background-image: url('<?php echo $thumb['0']; ?>')" class="inner-page-header">
<div class="wrap">
<div class="page_header">
<?php the_title(); ?>
</div>
</div>
</header>