Title: Comments.php not working
Last modified: August 20, 2016

---

# Comments.php not working

 *  Resolved [yuedesign](https://wordpress.org/support/users/yuedesign/)
 * (@yuedesign)
 * [13 years ago](https://wordpress.org/support/topic/commentsphp-not-working-1/)
 * The address is here [http://yuedesign.co.uk/wordpress/welcome/](http://yuedesign.co.uk/wordpress/welcome/)
 * Here’s the code
 *     ```
       <?php // Do not delete these lines
       if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!'); if (!empty($post->post_password)) { // if there's a password
       if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
       ?>
       <p class="nocomments">
       This post is password protected. Enter the password to view comments.
       </p>
   
       <?php return; } } /* This variable is for alternating comment background */ $oddcomment = 'class="alt" '; ?>
   
       <!-- You can start editing here. -->
   
       <?php if ($comments) : ?>
   
       <h2><?php comments_number('No responses', 'One response', '% responses' );?> to <?php the_title(); ?></h2>
   
       <p><?php foreach ($comments as $comment) : ?>
       <?php $PostAuthor = false; if($comment->comment_author_email == get_the_author_email()) { $PostAuthor = true;} elseif($comment->comment_author_email == 'youremail@email.com') { $PostAuthor = true;} ?>
   
       <li<?php if($PostAuthor) {echo "class='authorcomment' ";} ?><?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"></li>
   
       <?php if ($comment->comment_approved == '0') : ?><em>Your comment is awaiting moderation.</em></p>
   
       <?php endif; ?>
   
       <?php echo get_avatar( $comment, $size = '55', $default = 'image URL' ); ?>
       <h3><?php comment_author_link() ?> said:</h3>
       <p><?php comment_text() ?></p>
   
       <small>On the <?php comment_date('F jS, Y') ?>.</small>
   
       <?php /* Changes every other comment to a different class */ $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : ''; ?>
   
       <?php endforeach; /* end for each comment */ ?><?php else : // this is displayed if there are no comments so far ?><?php if ('open' == $post->comment_status) : ?><!-- If comments are open, but there are no comments. --><?php else : // comments are closed ?><!-- If comments are closed. --><p class="nocomments">Comments are closed.</p><?php endif; ?><?php endif; ?><?php if ('open' == $post->comment_status) : ?>
   
       <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
       <p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a comment.</p><?php else : ?><form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"><?php if ( $user_ID ) : ?>
   
       <?php if(function_exists('wp_commentnavi')) { wp_commentnavi(); } ?>
   
       <h2>Leave a reply</h2><BR>
   
       <?php else : ?>
       <h3>Leave a comment for <?php the_title(); ?></h3>
   
       <p><input type="text" name="author" id="name" value="Name" onfocus="if (this.value == 'Name') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Name';}" /></p>
   
       <p><input type="text" name="email" id="email" value="Email" onfocus="if (this.value == 'Email') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Email';}" /></p>
   
       <p><input type="text" name="url" id="url" value="http://" /></p>
   
       &lt
       ;?php endif; ?>
       <?php if ( function_exists(cs_print_smilies) ) {cs_print_smilies();} ?>
       <p><textarea name="comment" value="All comments needs to be approved by me first " class="comment" id="comment" cols="100%" rows="5" tabindex="4"></textarea></p>
   
       <p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" /></p>
   
       <p><input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /></p>
       <?php do_action('comment_form', $post->ID); ?></form>
   
       <?php endif; ?>
       <?php endif; ?>
       ```
   
 * I’m new to wordpress so i’m completely clueless ! I’m not sure what’s going wrong?

The topic ‘Comments.php not working’ is closed to new replies.

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [yuedesign](https://wordpress.org/support/users/yuedesign/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/commentsphp-not-working-1/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
