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 interested how to display all posts (from all categories) that have closed/disabled comments?

I have tried using the comments_open() function inside the loop, that works, i don't know how to enable pagination on it, and here's why:

wp query - here's the query that displays all posts, i set here how many per page should be displayed if (!comments are open) i list the posts

so, the problem here is that i want to show 10 posts per page -the loop actually goes through 10 posts, and displays any post of the given 10 that has closed comments, and then creates a second page with 10 posts and does the same etc...

I need a filter inside the loop itself, so i display 10 posts with disabled comments PER PAGE.

Pls, can anyone help with this?

share|improve this question

I don't have the time right now to work the code, but you'll need to use pre_get_posts and filter out based upon comment_status => 'open'.

share|improve this answer
I really appreciate your answer. Can you please post more details about this. I didn't find much tutorials and examples on this filter, but it seems it can do what i need :). – Nicholas Sep 11 '12 at 21:32

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.