Alternate Comments
When you first install a newer version of wordpress, they give you a theme called the Default theme by Kubrick. it's kinda neat how comment background change colors when they are displayed in this theme, but how do they do it if you make your own wordpress themes or layouts? it's pretty simple
My blog uses this function and it is fully customizeable when using basic .CSS.
Step 1: Put this tag at the top of your comments, popup-comments (if you use it), and header templates:
Find this line in your comments/popup-comments templates:
|
<small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>"
title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a> <?php
edit_comment_link('e','',''); ?></small>
|
And put this right in front of it:
|
<div class="<?=($i%2)?"color1":"color2";$i++;?>">
|
And then use the closing </div> tag after the php comment_text tag that looks like this:
So your whole section in comments.php (and comments-popup if you use it) should look like so:
|
<div class="<?=($i%2)?"color1":"color2";$i++;?>"><small class="commentmetadata"><a
href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?>
at <?php comment_time() ?></a> <?php edit_comment_link('e','',''); ?></small>
<?php comment_text() ?>
</div>
|
Now in your css stylesheet, define the two classes color1 and color2 like so:
|
.color1 {background-color: #ffffff;}
.color2 {background-color: #000000;}
|
now every other comment will be a different color!
|