loop – Exclude WooCommerce product category from product slider


I want to exclude a product category from displaying within a ‘latest products’ slider. This is the code I’m working with:

<section class="section latest-products">
  <div class="container w-100">
    <div class="columns">
      <div class="column">
        <div class="content">
           <h2 class="title"><?php echo $title;?></h2>
            <div class="slider-button">
              <i class="far fa-arrow-alt-circle-left products-next"></i>
              <i class="far fa-arrow-alt-circle-right products-prev"></i>
   <div class="column is-full">
    <div class="product-slider">
          $args = array(
            'post_type' => 'product',
            'posts_per_page' => 12,
            'post__not_in' => wc_get_product_ids_on_sale(),
          $loop = new WP_Query( $args );
          if ( $loop->have_posts() ) {
            while ( $loop->have_posts() ) : $loop->the_post();?>
              <ul class="products">
                <?php wc_get_template_part( 'content', 'product' );?>
          <?php endwhile;
          } else {
            echo __( 'No products found' );
    <div class="column is-full is-flex justify-content-center">
    <a class="has-text-centered button is-outlined" href="/shop/">View all stock</a>

Can anyone please advise how this can be achieved by changing the code above? Thanks in advance!

chuckgee007 4 months 2021-06-25T14:01:02-05:00 0 Answers 0 views 0

Leave an answer