Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Wordpress - loop based on post's comment status

loop

  • Please log in to reply
No replies to this topic

#1 Agent001

Agent001

    CC Regular

  • Member
  • PipPipPip
  • 41 posts

Posted 11 September 2012 - 09:06 AM

I want to loop through posts, and display only posts with comments status set to closed.


I have a custom query


<?php $the_query = new WP_Query('posts_per_page=10&cat=-42'); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<?php if (!comments_open()) : ?>


But the problem here is, as this is a "hack", it just deoesn't show the post if it's comments are closed.


If i introduce pagination, and this is the real problem, it will display a blank page if among the given 10 posts there aren't any with closed comments.


So, i want to STRICTLY display posts with closed comments, 10 such posts per page.


Any help would be appreciated.


  • 0





Also tagged with one or more of these keywords: loop

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download