This post is being written as part of the Geeks Are Sexy How-To Contest

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 == "admin@yourdomain.com") echo 'author'; else echo $oddcomment; ?> item" id="comment-<?php comment_ID() ?>">

You’ll want to modify admin@yourdomain.com 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 == "author@yourdomain.com") echo 'author'; else if ($comment->comment_author_email == "author2@yourdomain.com") echo 'author2'; else if ($comment->comment_author_email == "author3@yourdomain.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 author@yourdomain.com.   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 author2@yourdomain.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!

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Connect with Kyle on Twitter or Google+!

  1. Lucas Cepeda says:

    Hi!
    Nice post; I was just looking for this, but not in that way, though.
    If you “assign” the author verification to the email address, any of your readers could spoof it, by commenting filling your email in the comment form.

    Here Matt Cutts gives a, IMO, a better solution:
    http://www.mattcutts.com/blog/highlight-author-comments-wordpress/

    My two cents!

  2. Kyle Eslick says:

    @ Lucas – Thanks for the link! I try to offer hacks to do accomplish various things, but I can’t always promise they are the best way.

  3. Andol says:

    it is getting even simpler now in version 2.8. there is a new class added only for author.

  4. adam mayhad says:

    great article – will be using this on my blog which i’m currently making http://www.greencleansolution.co.uk, think i’m on to a unique idea which is going to vastly improve my income :)

  5. MiLaT says:

    thank you great article :)

  6. Cihan Aksu says:

    Seperating comments if really good and easy if you know if else. I Will give it a try, thanks my friend.

    p.s. : you can give a little tip about css for starting users

Trackbacks/Pingbacks »

  1. How To Separate Comments and Trackbacks On A WordPress Blog says:
  2. Yazar ile okuyucunun yorumlar?n? farkl? biçimlendirmek says:
  3. US Want - Your Blogs, Social Network, Search Engine for Drivers, UserGuide, Vids, Images, Tutorials says:
  4. 30 Wordpress Yorum Sayfas? Düzenlemesi | Sorbize says:
  5. MsKcR | Bilgi Payla??m Portal? » Blog » Wordpress Yorum Sayfas? Eklentileri says: