在我的WooCommerce商店中,我启用了"Hide out of stock items from the catalogue" . 此选项会导致 product variations on individual pages to become invisible .
我想申请"Hide out of stock items from the catalogue"选项 only on archive pages (search, categories) .
这是我的代码:
function featured_posts( $query ) {
if ( ! $query->is_main_query() ) return;
//What goes in here?
}
add_action( 'pre_get_posts', 'featured_posts' );
我怎样才能做到这一点?
谢谢
1 回答
你必须检查页面,如下所示