Title: Comments Conditional in Loop
Last modified: August 19, 2016

---

# Comments Conditional in Loop

 *  [withinsight](https://wordpress.org/support/users/withinsight/)
 * (@withinsight)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/comments-conditional-in-loop/)
 * 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.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/comments-conditional-in-loop/#post-1574350)
 * this is the only one i found so far (in the loop):
 *     ```
       <?php if($post->comment_count) { echo 'has comments'; } ?>
       ```
   
 *  Thread Starter [withinsight](https://wordpress.org/support/users/withinsight/)
 * (@withinsight)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/comments-conditional-in-loop/#post-1574465)
 * That works perfectly, thanks for the assist, alchymyth.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Comments Conditional in Loop’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [withinsight](https://wordpress.org/support/users/withinsight/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/comments-conditional-in-loop/#post-1574465)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
