<?php
$post_type = 'product';
$taxonomies = get_object_taxonomies(array(
'product' => $post_type
));
foreach ($taxonomies as $taxonomy):
$terms = get_terms($taxonomy);
foreach ($terms as $term): ?>
<?php
$args = array(
'post_type' => $post_type,
'posts_per_page' => - 1, //show all posts
'tax_query' => array(
array(
'taxonomy' => 'allproducts',
'field' => 'slug',
'terms' => $term->slug,
)
)
);
$posts = new WP_Query($args);
if ($posts->have_posts()): ?>
<?php $test = $term->name; ?>
<?php $cat_name = get_the_category_by_ID(3); ?>
<?php if ($cat_name == $test): ?>
<?php while ($posts->have_posts()):
$posts->the_post(); ?>
<?php if (has_post_thumbnail())
{ ?>
<?php the_post_thumbnail(); ?>
<?php
}
else
{ ?>
<li><a href="<?php the_permalink() ?>"><?php the_field('name_product') ?></a></li>
<?php
} ?>
<?php the_excerpt(); ?>
<?php
endwhile;
endif; ?>
<?php
endif ?>
<?php
endforeach;
endforeach; ?>
<div class="product_sidebar_img">
<img class="products_img" src="<?php the_field('product-images')?>">
<img src="<?php echo get_template_directory_uri();?>/img/shadow.jpg" alt="shadow">
</div>
$post_type = 'product';
$post_type = 'product';
$taxonomies = get_object_taxonomies(array(
'product' => $post_type
));
$post_type = 'product';
$taxonomies = get_object_taxonomies('product');