Answer the question
In order to leave comments, you need to log in
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; ?>
<?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; ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question