我正在使用WP\\u查询从类别中获取产品,
$default = array(
\'post_type\' => \'product\',
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'post_status\' => \'publish\',
\'showposts\' => $numberposts
);
if( $category != \'\' ){
$term = get_term_by( \'slug\', $category, \'product_cat\' );
if( $term ) :
$term_name = $term->name;
endif;
$default[\'tax_query\'] = array(
array(
\'taxonomy\' => \'product_cat\',
\'field\' => \'slug\',
\'terms\' => $category )
);
}
$list = new WP_Query( $default );
但我需要排除使用产品ID的少数产品,也可以在循环中使用一些if条件,但我需要将该过滤器应用于上述查询例如,我需要从上述查询中排除产品id 2024。
有人知道怎么做吗。非常感谢。