Have you noticed while visiting some of your favorite blogs that many author comments are styled differently to help the authors comments to stand out? This is something that isn’t overly difficult to implement on your WordPress blog, so I decided to write a quick how-to post explaining how you can easily adjust your WordPress theme to display different styles for each author.
First, you’ll need to make some adjustments to the comments.php code. Look for something similar to the following code:
<li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
Replace the above code with the following code:
<li class="<?php if ($comment->comment_author_email == "email@example.com") echo 'author'; else echo $oddcomment; ?> item" id="comment-<?php comment_ID() ?>">
You’ll want to modify firstname.lastname@example.org to reflect the primary blog author’s e-mail address. This will tell WordPress to check each comment to see if you are the author. Now go to your CSS Stylesheet (style.css) and add the commands you would like to use for your author comments. You’ll want to use .author to style your author comments. I recommend pulling your standard comment code, then adjusting the colors to look different on your comments. You can also add a logo through your stylesheet.
How do I do this if my blog uses multiple authors? If your blog features several different authors, you’ll want to make a slightly different adjustment to the above code so that it looks like this:
<li class="<?php if ($comment->comment_author_email == "email@example.com") echo 'author'; else if ($comment->comment_author_email == "firstname.lastname@example.org") echo 'author2'; else if ($comment->comment_author_email == "email@example.com") echo 'author3'; else echo $oddcomment; ?> item" id="comment-<?php comment_ID() ?>">
In the above example, we are assigning the primary author as .author and adding their e-mail address where it says firstname.lastname@example.org. When the comment includes that e-mail, it will use the .author style from the stylesheet. The second author will use .author2 for their stylesheet and replace email@example.com with the 2nd author’s e-mail, etc. Any comments that don’t include one of the above e-mails will use the standard styles.
Once you’ve got your code adjusted and added the author(s) commands to your stylesheet you will be ready to start commenting!