WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i'm using a custom query, which needs to display all posts with closed comments.

I have this

<?php $the_query = new WP_Query('showposts=-1'); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>

<?php if (!comments_open()) : ?>
//some posts fomatting
<?php endif; ?>

<?php endwhile;?>

So, basically, this loops through all posts, and then displays only the ones with the closed comments.

It works, but i want to introduce the pagination to it. If i say posts_per_page instead of showposts, it doesn't work.

Any help would be appreciated :).

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.