I like when blog owner reply to comments about their post and I like it even more when there is something to tell me the reply is from the admin or from a normal user.
I’ve seen it done on a few good website like Perishable press or Css-tricks. The easy way if you use gravatar is to have a well recognisable avatar. But even that is not enough in some cases.
So here is a quick way to find in php if the author of the comment is the author of the post, add add a class if it is. This solution works if when replying your are logged in (same user as the author) or if you use the same email address as the post author.
<?php
//somewhere in your comments.php file in your template folder
foreach ($comments as $comment) : ?>
<?php
//this is where we do the check using two built in function from wordpress
//this read like: "if comment's author email is the same as post's author email
//then class as the value of 'author'. If not class is null
$class = get_comment_author_email() == get_the_author_email()? 'author': '';
//then add the $class where you want it with a simple echo $class
?>
<h5 class="commentAuthor <?php echo $class ?>"><?php comment_author_link() ?></h5>
<div class="comm <?php echo $class ?>">
<?php if ($comment->comment_approved == '0') : ?>
<b>Your comment is awaiting moderation.</b>
<?php endif; ?>
<h4><?php comment_date('d/m/y') ?><?php edit_comment_link('e','',''); ?></h4>
<?php comment_text() ?>
</div>
<?php /* Changes every other comment to a different class */
if ('alt' == $oddcomment) $oddcomment = '';
else $oddcomment = 'alt';
?>
<?php endforeach; /* end for each comment */ ?>
This is a very simple trick but is works (at least on my test page :p). Now if a user comment on your post and give the same email address as the author then it will give it the class author as well. So be careful when you approve a post and check the email address too.
Related Items and Services:TNT courier service here
Freight Forwarders available here
New International Parcel Services
Same Day Couriers available here












Comments