Alternating Colors for Comments

I snagged this nice idea from gfmorris about how to make comments in WordPress stand out from one another. I changed the code a little because his quotes didn’t work for me.

Starting at about line 37, add the items in red to wp-comments.php:

<?php $j=0; foreach ($comments as $comment) { ?>
<li id="comment-<?php comment_ID() ?>" <?php if($j%2) {echo "<div class="comment-even">";} else {echo "<div class="comment-odd">";} $j++; ?>

Finally, put these in your wp-layout.css

.comment-even {background: #CECECE;}
.comment-odd {background: #F0F0F0;}

An example of what you might get out of this is in the neighboring image.

Leave a Comment

Do not write "http://" or "https://" in your comment, it will be blocked. It may take a few days for me to manually approve your first comment.