Forums

Comments Conditional in Loop (3 posts)

  1. withinsight
    Member
    Posted 2 years ago #

    How do you determine if there are comments within the loop in single.php? I've tried have_comments(), using the global $comments variable, and even comments_number(), and nothing seems to work.

    I'm able to display the number of comments in the loop by using comments_number(), but I need to setup a conditional so that if comments_number = 0, don't display anything.

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    this is the only one i found so far (in the loop):

    <?php if($post->comment_count) { echo 'has comments'; } ?>
  3. withinsight
    Member
    Posted 2 years ago #

    That works perfectly, thanks for the assist, alchymyth.

Topic Closed

This topic has been closed to new replies.

About this Topic