我需要创建一个产品存档页面(通常是WooCommerce中的Shop页面),但只显示ON SALE产品.基本上,它应该使用相同的模板布局为中.主菜单中将有一个指向此页面的链接.我该怎么做?archive-product.php
我设法过滤掉了SALE产品,下面的代码位于if ( have_posts() ) :线上方......
$args = array(
'post_type' => 'product',
'order' => 'ASC',
'paged' => $paged,
'meta_query' => array(
array(
'key' => '_sale_price',
'value' => 0,
'compare' => '>',
'type' => 'numeric'
)
)
);
query_posts( $args );
Run Code Online (Sandbox Code Playgroud)
代码放在我命名并作为页面模板制作的副本中.archive-product.phparchive-product_sale.php
但是,这仅适用于Simple产品类型,我需要它适用于Simple产品和Variable产品类型.