Support » Fixing WordPress » How to update comments.php to include wp_list

  • How/what do i update in my comments.php to take advantage of the wp_list_comments template tag? My theme has not been updated since wp version 2.6

    here is my comments.php

    <?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;
    }
    }
    $oddcomment = 'class="alt" ';
    ?>
    
    <!-- Begin Comments List -->
    <?php if ($comments) : ?>
    <h2 id="comments"><?php comments_number('No Comments', 'One Comment', '% Comments' );?> on “<?php the_title(); ?>”</h2>
    <ul class="commentlist">
    <?php foreach ($comments as $comment) : ?>
    <?php $comment_type = get_comment_type(); ?>
    <?php if($comment_type == 'comment') { ?>
    <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">
    
    <div class="avatar"><?php echo get_avatar( $comment, 50 ); ?></div>
    
    <div class="commentinfo">
    <span class="cauthor"><?php comment_author_link() ?></span> <span class="cdate">wrote on <?php comment_date('j F, Y, G:i'); ?></span><?php edit_comment_link('edit','&nbsp;&nbsp;',''); ?>
    <span class="ctext"><?php comment_text() ?></span>
    <?php if ($comment->comment_approved == '0') : ?><span class="approve">Your comment is awaiting approval.</span><?php endif; ?>
    </div><div class="clear"></div>
    
    </li>
    <?php $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : ''; ?>
    <?php } else { $trackback = true; } /* End of is_comment statement */ ?>
    <?php endforeach; ?>
    </ul>
    <!-- End Comments List -->
    
    <!-- Setup Trackbacks box -->
    <?php if ($trackback == true) { ?>
    <h4>Trackbacks</h4>
    <ol class="trackbacks">
    <?php foreach ($comments as $comment) : ?>
    <?php $comment_type = get_comment_type(); ?>
    <?php if($comment_type != 'comment') { ?>
    <li><?php comment_author_link() ?></li>
    <?php } ?>
    <?php endforeach; ?>
    </ol>
    <?php } ?>
    <!-- End Trackbacks display -->
    
    <!-- Leave a Reply Box -->
    <?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. -->
    
    <?php endif; ?>
    <?php endif; ?>
    
    <?php if ('open' == $post->comment_status) : ?>
    
    <h2 id="respond">Write a Comment</h2>
    
    <p>Gravatars are small images that can show your personality. You can get your <a href="http://gravatar.com"><b>gravatar</b></a> for free today!</p>
    
    <?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 class="replyform" action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    <fieldset>
    
    <?php if ( $user_ID ) : ?>
    <p style="line-height: 1.5em">Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Log out &raquo;</a></p>
    
    <?php else : ?>
    <label for="author">Name <?php if ($req) echo "(required)"; ?></label>
    <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" tabindex="1" class="replytext" <?php if ($req) echo "aria-required='true'"; ?> />
    <label for="email">Mail <?php if ($req) echo "(required)"; ?></label>
    <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" tabindex="2" class="replytext" <?php if ($req) echo "aria-required='true'"; ?> />
    <label for="url">Website</label>
    <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" tabindex="3" class="replytext" />
    <?php endif; ?>
    <label for="comment">Comment</label>
    <textarea name="comment" id="comment" tabindex="4" class="replyarea"></textarea>
    <input name="submit" type="submit" id="submit" tabindex="5" value="Send Comment" class="replybutton" />
    <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
    <?php do_action('comment_form', $post->ID); ?>
    
    </fieldset>
    </form>
    <!-- End Leave a Reply Box -->
    
    <?php endif; // If registration required and not logged in ?>
    <?php endif; // if you delete this the sky will fall on your head ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to update comments.php to include wp_list’ is closed to new replies.