Title: PHP code glitching on comments_open()
Last modified: August 22, 2016

---

# PHP code glitching on comments_open()

 *  [DDS_nl](https://wordpress.org/support/users/dds_nl/)
 * (@dds_nl)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/php-code-glitching-on-comments_open/)
 * I’m trying to add a tiny suffix to article titles, which would show the visitors
   how many comments a given article has. But, if the the comment section is closed,
   it gives me a big and nasty ‘comments closed’ remark. I don’t want that.
 * So I’ve tried my hand at PHP to disable this ‘comments closed’ remark. Here’s
   my code:
 * `<?php if ( comments_open() ) { comments_popup_link( '0', '1', '%' ); } else {&
   nbsp; } ?>`
 * Except: it doesn’t work. It just refuses to load half the page if I enter this
   code. I’m really not sure how this php code is faulty, so I would be grateful
   if someone could point out to me what I did wrong.

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

 *  Moderator [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * (@jcastaneda)
 * THEME COFFEE MONKEY
 * [11 years, 1 month ago](https://wordpress.org/support/topic/php-code-glitching-on-comments_open/#post-5776373)
 * Not sure if you found your answer but try:
 *     ```
       if ( comments_open() ) :
         echo '<p>';
         comments_popup_link( '0', '1', '%', 'comments-link', '');
         echo '</p>';
       endif;
       ```
   
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/php-code-glitching-on-comments_open/#post-5776374)
 * enable DEBUG to see any error messages;
    [http://codex.wordpress.org/Debugging_in_WordPress](http://codex.wordpress.org/Debugging_in_WordPress)
 * right now, you are inserting html (that is the ` `) directly into php.
 * you don’t need the **else **part if it is not doing anything;
 * try to simplify the code to:
 *     ```
       <?php if ( comments_open() ) { comments_popup_link( '0', '1', '%' ); } ?>
       ```
   
 * or correctly close and open the php tags like:
 *     ```
       <?php if ( comments_open() ) { comments_popup_link( '0', '1', '%' ); } else { ?>   <?php } ?>
       ```
   

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

The topic ‘PHP code glitching on comments_open()’ is closed to new replies.

## Tags

 * [Comments](https://wordpress.org/support/topic-tag/comments/)
 * [comments closed](https://wordpress.org/support/topic-tag/comments-closed/)
 * [comments_open](https://wordpress.org/support/topic-tag/comments_open/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/php-code-glitching-on-comments_open/#post-5776374)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
