Alternate background color in wordpress comments list

November 11, 2008

If you have a large amount of comments on your blog, it can be very more readable to alternate background colors. Edit the comments.php file from your theme. First, find the following line: <?php if ( $comments ) : ?> Once you found it, replace the comment loop by the following code: <ul> <?php $i = 0; ?> <?php foreach ($comments as $comment) : ?> <?php $i++; ?> <li id="comment-<?php comment_ID() ?>" <?php if($i&1) { echo 'class="odd"'; } else { ... [Read the full story]