V
V
Vitaly2017-02-28 16:37:06
WordPress
Vitaly, 2017-02-28 16:37:06

How to loop Woocommerce product category?

<div class="bags_slider product_slider">
            <?php if ( have_posts() ) : query_posts('cat=2');
            while ( have_posts() ) : the_post(); ?>
              <div class="product_item">
                <div class="product_circle">
                  <?php echo get_the_post_thumbnail(); ?>
                </div>
                <div class="colors">
                  <div class="dark_grey"></div>
                  <div class="red"></div>
                  <div class="black"></div>
                </div>
              </div>
              <?php endwhile; endif; wp_reset_query(); ?>
            </div>

you need to display it not as a shortcode, but as a cycle in order to insert the necessary record fields into the required markup.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Mavlikhanov, 2017-02-28
@Gori4ka

query_posts('product_cat=2');

<div class="bags_slider product_slider">
            <?php
query_posts('cat=2');
 if ( have_posts() ) : 
            while ( have_posts() ) : the_post(); ?>
              <div class="product_item">
                <div class="product_circle">
                  <?php echo get_the_post_thumbnail(); ?>
                </div>
                <div class="colors">
                  <div class="dark_grey"></div>
                  <div class="red"></div>
                  <div class="black"></div>
                </div>
              </div>
              <?php endwhile; endif; wp_reset_query(); ?>
            </div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question