• Hello to all the WordPress geeks.

    I want to show the list of only those posts which have comments open.

    I want to send my users on a page where they can select a post to comment from the list of posts where comments are open and allowed but yet not closed. And if comments are closed it should be removed from the list.

    How is that possible? Please help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello
    Please try this code.

    $r = new WP_Query( array(
    			'posts_per_page'      => '-1',
    			'no_found_rows'       => true,
    			'post_status'         => 'publish',
    			'ignore_sticky_posts' => true,
    			'comment_status' =>'open'
    		) ) ;
    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Side note and off topic: @distinctcoder Thanks for the help but spreading your site link like that is spamming. Please don’t, OK?

    You’ll get into trouble here if you do that again.

    Thread Starter laddi

    (@laddi)

    Thank you so much @prakashitobuz

    But I tried this code:

    <ul class="addme">
    <?php $the_query = new WP_Query('showposts=-1'); ?>
    <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
    <?php if (comments_open()) : ?>
    <li><a href="<?php echo get_permalink( $post->ID ); ?>#new-post"><?php the_title(); ?></a> <span class="post-count"><?php comments_number( '0 Post', '1 Post', '% Posts' ); ?></span></li>
    <?php endif; ?>
    <?php endwhile;?>
    </ul>

    And it’s working Okay?
    Now, I want to know that is this code Okay?…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show List of Posts With Comments Open Only’ is closed to new replies.