Answer the question
In order to leave comments, you need to log in
Why are unwanted records displayed?
On the page of a certain category, I'm trying to display posts from this category. The output goes without problems if this rubric has entries. However, if it has no entries, then only the most recent entries from all categories are displayed. I don't understand why this is happening. It is necessary that if there are no records in this category, "No records" is displayed.
<?php
$cat = $fields['category']; // определённая категория
if(have_posts()) : query_posts("showposts=3&cat=$cat");
while(have_posts()) : the_post();
?>
<div><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<?php
endwhile;
else: ?> Записей нет <?php
endif;
wp_reset_query();
?>
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