has moved and is now available at

WordPress: Author comment highlighting

22 November 2006

I’ve seen it lots of times before, but I just added it to (and the next release of the iAriejan theme). Sometimes there are lots of comments and it’s nice for visitors to see what the official reaction of the blog author is.

Since I haven’t really looked into a plugin or anything, this is just a very simple theme hack.

You can apply it to your current theme with almost no effort at all.

Open up your comments.php file in your themes directory. And look for the following code:

<li class="<?php echo $oddcomment; ?>" id="comment-< ?php comment_ID() ?>" id="comment-< ?php comment_ID() ?>">

and replace it with

<li class="<?php if ( $comment->comment_author_email == get_the_author_email() ) echo 'authorcomment'; else echo $oddcomment; ?>" id="comment-< ?php comment_ID() ?>" id="comment-< ?php comment_ID() ?>">

What this will do is match the e-mail address of the poster with the e-mail address of the post author. This is in some way spoofable, as users may be able to post a comment with your e-mail address on it.

If you posted the comment an extra CSS class named ‘authorcomment’ is added. So add the following to your style.css file. (You may change this to suit your own taste of course):

.authorcomment {
    background-color: #363636;
    border: 1px solid #969696;

To prevent this you can add your e-mail address (the one you use with your WP account) to Options -> Discussion -> Comment Moderation. This will keep any post that contains your email address back for moderation by you. This is the only fool-proof method I know right now to keep people from spoofing. There might be some other hacks for this, but I haven’t had time to think about that yet.