How to style Author comments

Posted on February 5th, 2011

1. Highlight Author Comments
How to make the author comments look fabulous? Newer versions of WordPress come equipped with a specific “author” class that may be targeted with the CSS of your choice. For older versions of WordPress, custom class attributes are to be added with a little PHP magic.
First, open your theme’s comments.php template and add the following code snippet in the (X)HTML element that contains the comment information:
<divcomment_author_email == “email@domain.tld”) echo ‘ class=”author”‘; ?> id=”comment-”>
.
.
.

After changing the email address to the original one (i.e., the one used for your WP Admin user profile), style it up with a little CSS:
.author {
background: red !important;
color: yellow !important;
}
This will make author comments to appear with yellow text on a red background. Anything is possible.
For blogs with multiple authors, you can style each of their comments differently as well by using something like this:
<divcomment_author_email == “email-01@domain.tld”) echo ‘ class=”author-01″‘; elseif ($comment->comment_author_email == “email-02@domain.tld”) echo ‘ class=”author-02″‘; elseif ($comment->comment_author_email == “email-03@domain.tld”) echo ‘ class=”author-03″‘; ?> id=”comment-”>
.
.
.

Replace each of the email addresses with those of the various authors. Style to taste.
2. Drop-Dead Easy Styles for Author Comments
This is almost too easy. To make your Author comments stand out from the crowd in WordPress 2.7 or better, use this code to apply some custom CSS styles:
li.bypostauthor {
background: red;
color: white;
}
li.byuser {
background: white;
color: black;
}