Woocommerce don';不显示特定的商业类别

Woocommerce don';不显示特定的商业类别,woocommerce,show-hide,product,categories,Woocommerce,Show Hide,Product,Categories,我有这个代码,用于在移动主题中将新产品显示为hscroll 但我不想显示具有1230 id的类别产品 我添加了一些代码,比如:$products->category->!=1230到第一个如果 请引导 <?php // new arrivals products $new_args = array( 'post_type' => 'product', 'posts_per_page' => 8, 'orderb

我有这个代码,用于在移动主题中将新产品显示为hscroll 但我不想显示具有1230 id的类别产品

我添加了一些代码,比如:
$products->category->!=1230
到第一个如果 请引导

<?php
    // new arrivals products
    $new_args = array( 
        'post_type' => 'product', 
        'posts_per_page' => 8,
        'orderby' =>'date',
        'order' => 'DESC'
    );
    $products = new WP_Query( $new_args );
?>


<?php if ( $products->have_posts() ) { ?>
<div class="title-intro content-block-title"><?php _e( 'New Arrivals', 'woomobify' ); ?></div>
<div class="product-hscroll swiper-container swiper-init" data-auto-height="true" data-free-mode="true" data-slides-per-view="auto">
    <div class="swiper-wrapper">

        <?php while ( $products->have_posts() ) : $products->the_post(); global $product; ?>

        <div class="swiper-slide">
            <div class="card">
                <div class="card-content">
                    <a href="<?= get_the_permalink(); ?>">
                        <?php 
                        if ( has_post_thumbnail($products->post->ID) ) {
                            echo get_the_post_thumbnail( $products->post->ID, 'shop_catalog' ); 
                        } else {
                            echo '<img src="'.wc_placeholder_img_src().'"/>'; 
                        } ?>
                    </a>

                        <div class="title"><?php the_title(); ?></div>
                        <div class="item-text product-price">
                            <span class="price"><?= wc_price( $product->get_price() ); ?></span>
                        </div>  </div> </div>
        <?php endwhile; ?>

我想您正在寻找的解决方案在

或者为了更简单,使用下一个参数检索所有产品,除非该产品属于类别(id)1230

$args = array(
  'posts_per_page' => -1,
  'orderby' =>'date',
  'order' => 'DESC',
  'tax_query' => array(
    array(
        'taxonomy'      => 'product_cat',
        'field'         => 'id',
        'terms'         => array('1230'),
        'operator'      => 'NOT IN')));