F
F
flappyflappy2016-06-20 04:33:03
Taxonomy
flappyflappy, 2016-06-20 04:33:03

How to correctly display posts related only to a certain taxonomy?

Hello!
I have a custom post type: Products. A cycle of these posts is displayed on the page-product.php page:

<?php $tovary = new WP_Query( array('post_type' => 'tovary', 'order' => 'DESC', 'nopaging' => 'TRUE') ); ?>
<?php if ($tovary->have_posts()) :  while ($tovary->have_posts()) : $tovary->the_post(); ?>
<section>
  <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
  <p><?php the_excerpt(); ?></p>
  <a href="<?php the_permalink(); ?>">Узнать подробнее</a>
</section>
<?php endwhile; ?>
<?php else: ?>
<p>Пока товаров нет</p>
<?php endif; ?>

There is also a taxonomy for it: Product categories. The Taxonomy.php template itself, outputs the following loop:
<?php $tovary = new WP_Query( array('post_type' => 'tovary', 'meta_key' => 'sort-post-course', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'nopaging' => 'TRUE') ); ?>
<?php if ($tovary->have_posts()) :  while ($tovary->have_posts()) : $tovary->the_post(); ?>
<section>
  <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
  <p><?php the_excerpt(); ?></p>
  <a href="<?php the_permalink(); ?>">Узнать подробнее</a>
</section>
<?php endwhile; ?>
<?php else: ?>
<p>Пока товаров нет</p>
<?php endif; ?>

Created two headings in the taxonomy "Categories of goods", these are: "Face care" and "Body care". For them, I created separate records: "Face mask company 01" (published in the taxonomy section "Face care"), and the product record "Shower gel" (published in the taxonomy section "Body care"). But when I go to the "Face care" taxonomy section, I get ALL product records, even those that I put in this taxonomy section! Also with other headings-taxonomies! How to fix it? How to make it so that when switching to a separate taxonomy heading, only those product records that belong to this taxonomy heading are displayed. I would be very grateful if you help me!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question