
<?php foreach ($comments as $comment) : ?>This is part of the comment loop. Each time a comment is to be printed the code starts here so we put the conditions after that.
<?phpThe comment is checked and if the email address used by the commenter is you, a variable is set which will be checked later.
$isByAuthor = false;
if($comment->comment_author_email == 'you@your_email_address') {
$isByAuthor = true;
}
?>
<?phpYou could add others if you want.
$isByFriend = false;
if($comment->comment_author_email == 'friend@their_email_address') {
$isByFriend = true;
}
?>
<?phpThere's not a lot to alter there - just copy it into the comments.php file.
$istback = false;
if($comment->comment_type == 'trackback') {
$istback = true;
}
?>
<?php
$ispingb = false;
if($comment->comment_type == 'pingback') {
$ispingb = true;
}
?>
<?php comment_text() ?>That line actually puts the comment out, so it's the part we want to style.
<?php if($isByAuthor ) { echo '<div class="authorcomment">';} ?>The above checks to see if the condition $isByAuthor is true. If it IS, a style starts. If it not, nothing happens. Then the comment is written and then the style is closed.
<?php comment_text() ?>
<?php if($isByAuthor ) { echo '</div>';} ?>
<?php if($isByAuthor ) { echo '<div class="authorcomment">';} ?>For every condition above, add a line below.
<?php if($isByfriend ) { echo '<div class="friendcomment">';} ?>
<?php if($istback ) { echo '<div class="tbcomment">';} ?>
<?php if($ispingb ) { echo '<div class="pbcomment">';} ?>
<?php comment_text() ?>
<?php if($isByAuthor ) { echo '</div>';} ?>
<?php if($isByFriend ) { echo '</div>';} ?>
<?php if($istback ) { echo '</div>';} ?>
<?php if($ispingb ) { echo '</div>';} ?>
.authorcomment {It's not particularly interesting, but you will need a class in the css for each style.
background: #eceef3;
}
.tbcomment {
padding: 5px;
background: url(images/tb.png) no-repeat;
}
.pbcomment {
padding: 5px;
background: url(images/pb.png) no-repeat;
}
<?php if ( $comments ) : ?>
<?php $i = 0; ?>That new line sets the counter at zero.
<?php if ( $comments ) : ?>
<?php foreach ($comments as $comment) : ?>That increases the counter by one each time a comment gets printed.
<?php $i++; ?>
<span class="count">and that is directly above the comment code that was added to style the comments. For example, my code looks something like this:
<?php echo $i; ?>
</span>
<span class="count">Get the idea ? Now to style it....
<?php echo $i; ?>
</span>
<?php if($isByAuthor ) { echo '<div class="authorcomment">';} ?>
<?php if($istback ) { echo '<div class="tbcomment">';} ?>
<?php if($ispingb ) { echo '<div class="pbcomment">';} ?>
<?php comment_text() ?>
.count {Change to suit your needs.
float:right;
font-size:26px;
color:#333
}
These pages are independent of http://wordpress.org
All design, content & images © Mark 2004-2008. All rights reserved.