• 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.

The topic ‘Loop posts based on comments status (comments_open or similar)’ is closed to new replies.