Duplicated cycle woocommerce?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
85 views
Hi guys!
Can't figure out what the problem is. On the page taking several cycles to display products from different categories, each group of goods in your unit. But faced with the fact that regardless of, I specify the taxonomy slug or not, all blocks appear the same mixed products from different categories. Tell me where I made a mistake.

An example of the first query 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(); ?> <?php the_post_thumbnail('tglavnaya'); ?><?php the_title(); ?>Read more<?php the_excerpt(); ?> <? echo $product->get_price_html(); ?>Order<?php endwhile; ?><?php wp_reset_postdata(); ?><?php endif; ?>


An example of the second block and other categories products

<?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(); ?> <?php the_post_thumbnail('tglavnaya'); ?><?php the_title(); ?>Read more<?php the_excerpt(); ?> <? echo $product->get_price_html(); ?>Order<?php endwhile; ?><?php wp_reset_postdata(); ?><?php endif; ?>
by | 85 views

1 Answer

0 like 0 dislike
And if so, these lines:
'tax_query' => 'pechati-v-metallicheskom-korpuse');

change to:
'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => 'pechati-v-metallicheskom-korpuse' ) )


P. S. If you want to withdraw goods previously separated by headings on a single page, it is possible to create several cycles, and to use 2 nested loops. Be the first to get the taxonomy term and the second term goods.
A similar example - https://gist.github.com/DevinWalker/6fb2783c05b46a...
by

Related questions

0 like 0 dislike
1 answer
asked Aug 20, 2019 by bokovua
0 like 0 dislike
1 answer
asked Jul 18, 2019 by bokovua
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,392 users