Answer the question
In order to leave comments, you need to log in
Duplicate woocommerce cycle?
Hi guys!
I can't figure out what the problem is. I display several cycles on the page to display products from different categories, each group of products in its own block. But I came across the fact that regardless of whether I specify the taxonomy slug or not, all blocks display the same products mixed from different categories. Please tell me where I made a mistake.
Example of the first request to one category
<?php
$params5 = array('post_type' => 'product',
'posts_per_page' => 2,
'tax_query' => 'aksessuary-i-rashodnye-materialy');
$wc_query5 = new WP_Query($params5);
?>
<?php if ($wc_query5->have_posts()) : ?>
<?php while ($wc_query5->have_posts()) :
$wc_query5->the_post(); ?>
<div class="item">
<?php the_post_thumbnail('tglavnaya'); ?>
<h2><?php the_title(); ?></h2>
<h4><span class="tooltip">Подробнее<span class="tooltip-text"><?php the_excerpt(); ?></span></span></h4>
<h5> <? echo $product->get_price_html(); ?></h5>
<div class="g2011164 zakazat">Заказать</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
<?php
$params4 = array('post_type' => 'product',
'posts_per_page' => 20,
'tax_query' => 'pechati-v-metallicheskom-korpuse');
$wc_query4 = new WP_Query($params4);
?>
<?php if ($wc_query4->have_posts()) : ?>
<?php while ($wc_query4->have_posts()) :
$wc_query4->the_post(); ?>
<div class="item">
<?php the_post_thumbnail('tglavnaya'); ?>
<h2><?php the_title(); ?></h2>
<h4><span class="tooltip">Подробнее<span class="tooltip-text"><?php the_excerpt(); ?></span></span></h4>
<h5> <? echo $product->get_price_html(); ?></h5>
<div class="g2011164 zakazat">Заказать</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
Answer the question
In order to leave comments, you need to log in
What if these lines are:
change to:
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => 'pechati-v-metallicheskom-korpuse'
)
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question