Title: ?php if ( have_comments() ) : ?
Last modified: August 20, 2016

---

# ?php if ( have_comments() ) : ?

 *  [King818](https://wordpress.org/support/users/king818/)
 * (@king818)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/php-if-have_comments/)
 * I would like to use the have no comment php command to write a brief italicized
   message as to what the comment should contain on pages where no comment is already
   written. theme is stripay. all other pages with comments already written should
   display as is with the comments and without the direction. any help is greatly
   appreciated as i have already googled as much as i can and am using this as a
   last resort. thanks to anyone who can lead me in the right direction this is 
   a critical element to my site.

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

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years, 8 months ago](https://wordpress.org/support/topic/php-if-have_comments/#post-2996275)
 * Would `get_comments()` work in your case?
 *     ```
       <?php
        if ( !get_comments() ) {
         //message
        }
       ?>
       ```
   
 * [http://codex.wordpress.org/Function_Reference/get_comments](http://codex.wordpress.org/Function_Reference/get_comments)
 *  Thread Starter [King818](https://wordpress.org/support/users/king818/)
 * (@king818)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/php-if-have_comments/#post-2996426)
 * Is there a specific way I should use it? I have looked through the document but
   couldn’t locate the part I needed.
 *  Thread Starter [King818](https://wordpress.org/support/users/king818/)
 * (@king818)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/php-if-have_comments/#post-2996455)
 * Anyone? This is an integral part of my site as it is comment dependant. Thanks
   guys. If you have any leads at all please let me know.
 *  Thread Starter [King818](https://wordpress.org/support/users/king818/)
 * (@king818)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/php-if-have_comments/#post-2996458)
 * For anyone incoming off of Google and wishing to learn how to do this, I managed
   to figure out a legitimate workaround.
 * I ended up using ‘comments_popup_link’ and used it as follows:
 * `<?php comments_popup_link('</a>NO COMMENT MESSAGE DISPLAY TEXT GOES HERE', '
   <div style="visibility: hidden"> </div>', '<div style="visibility: hidden"> </
   div>'); ?>`
 * The way this works is by using a code which displays how many comments the page
   currently has, and then linking to the pages leave a comment field. You have 
   three fields in the ”,”,”, and by default they are ‘0 comments’,’1 comment’,’%
   commments’. I used a visibility hidden code to kill the last two fields, and 
   then replaced the default 0 comments with my display text. I also before displaying
   the text put a `</a>` attribute which killed the link which would otherwise show
   up and link you to leaving a comment for the page.
 * I then placed this in comments.php, in my case line 70.
 * Done!

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

The topic ‘?php if ( have_comments() ) : ?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [King818](https://wordpress.org/support/users/king818/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/php-if-have_comments/#post-2996458)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
