I'm not sure what I'm doing wrong. None of my WP_Queries are returning the given number of posts. From what I can tell, it's returning all of them. How do I fix this? Here is the code I'm currently using for my loops:

<?php wp_reset_query(); ?>
<?php $review = new WP_Query(array(
    "posts_per_page" => 1,
    "category_name" => "reviews",
    'nopaging' => true
)); ?>
<?php if($review->have_posts()): while($review->have_posts()): $review->the_post(); ?>
    <!-- Everything here works as expected -->
    <?php break; ?> <!-- I have to break the loop by force, which is bad -->
<?php endwhile; else: ?>
    <!-- Placeholder content goes here -->
<?php endif; ?>
<?php wp_reset_postdata(); ?>

What am I doing wrong? How do I fix this?

1 Answer 1


nopaging=true override posts_per_page and sets it to -1 which will return all posts. Remove that and you should be fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.