How to Distinguish Author Comments on Your Blog

Nov 29th, 07 | 12 remarks

One of my readers asked a good question today about how to differentiate author comments from those made by readers. It never occurred to me to write a tutorial on something like that, so thanks goes out to Chris Coyier for the idea. He has a nice looking blog and also writes about CSS (and Wordpress), so if you like this site you might want to check out his site as well!

Okay, getting started. Open up your comments.php file. (This tutorial assumes you’re using Wordpress as your blogging platform, by the way). Look for your opening OL tag. Using the default theme as an example, you should see something like this about 1/4 of the way down the page:

Depending on how your theme is set up, next you might see the statement within the LI tag which instructs WordPress to echo the comment if it’s approved. We don’t want to go straight into that yet. Instead, we’re going to insert some code telling WP to also check if it’s an author comment. Here’s how it looks in my comments.php file (I removed the Gravatar code for brevity’s sake):

<?php if ($comment->comment_author_email=="charity@designadaptations.com") echo 'author';
    else echo $oddcomment; ?>

This runs a comparison against whatever email address you entered as the administrator of your blog, so be sure you use that one if you want it to work. I you plan on having guest bloggers, you could also add this between echo ‘author’; and else echo:

else if ($comment->comment_author_email == "guest@email.com") echo 'specialguest';

Now you’ll have to add some styles to your CSS. The Web Developer Toolbar for Firefox is incredibly handy for this, because it’ll show you the elusive hooks used in WP’s core code which are used for identifying author comments. If you have it, hit Cmd+Shift+Y (Ctrl+Shift+Y on PC) and hover over a test author comment in your browser to see what I’m talking about.

Here’s how my style sheet looks:

.cite { /*for reader comments */
float:left;
margin:0;
padding:5px;
font-size:1em;
width:120px;}
.cite img{padding-right:5px;}
.cite a{font-weight:bold;}
.comment_content{float:right; width:390px;}

li.author .comment_text{/*for author comments*/
color:#222;
border:solid 1px #69c;
background: #69c url(images/auth_comments.jpg) top left;}
li.author .cite a{color:#333!important;}
li.author .cite a:hover{color:#fff!important;}
li.author .cite .commentmeta a{color:#333!important;}
.author .comment_text p a {color:#fff !important;}

Notice I had to override the inherited rules (from the .cite class) by adding the !important keyword. You may or may not have to do this depending on your styling hooks and how they cascade.

That should be all there is to it! Having your comments visually distinguished from others is not only helpful to readers, but to you as the author if you need to refer back to something you said earlier. ;) It’s also a nice addition to the “curbisde appeal” of your site. Enjoy!


  1. Small Potato

    Nice tutorial. This will come in handy for my blog as more designers blog on it.


  2. cpanel web hosting

    wow, finally a tutorial on this that doesn’t require a doctorate degree in php and css. thanks!


  3. Chris Coyier

    Wow! My wish has come true =)

    This is an awesome tutorial, I’m going to work on implementing it my own blog right now, I’ll let you know how it goes.


  4. Charity

    Thanks all, and hopefully I didn’t leave anything out! =)



  5. Charity

    Nicely done Chris, and you’re welcome! :)


  6. Ehab

    Nicely done ! One of the easiest tuts I came across for stylin’ comments.


  7. LaurenMarie - Creative Curio

    Well I found this very useful and it’s going in my del.icio.us bookmarks for when I redesign my blog! (ah, someday…) Thank you, Charity!


  8. Lil DIva

    Thanks for the tutorial! There’a a plug in for this but I rather try your tip. One question: how do I add color to the commentors name like you have it here?


  9. 4 Useful Wordpress Resources - Part 1 | Pachecus.com

    [...] How to differentiate author comment: Charity from DesignAdaptations.com wrote an useful tutorial about it. [...]


  10. DirectToIndia

    This is nice and looks pretty cool.


  11. ari4u

    Would it be easier to use “the_author_email();” instead of hardcoding the email address in the code? This way, if the author changes email address in admin panel, there wont be a change to the code. Most probably should work for blogs with single author, not sure about multiple authors.

    Let me know if i am completely off tangent.
    Great tutorial btw.!

Post your remark

Other Recent Articles

In Reviews »

Clever Development With Coda

07/15/08
If you follow design related blogs, it seems you can't click a mouse anymore without Coda's icon making an appearance. I heard about this software long before buying my Mac, but because it's exclusive to that platform, I was never able to give it a test run. Now eight ... [ » ]

In Inspiration »

Have You Ever?

06/25/08
If you know me very well, you know how important music is in my life. It's playing at all times in my house, and I embrace all kinds of genres. I don't talk about it much on this blog, but I should. Music and creativity, in my opinion, are inextricably ... [ » ]

In Design »

The Evolution of a Logo (I Can Live With)

06/19/08
One of the most frustrating things for me since I started writing on this blog was the lack of a logo I really loved. That's not to say I haven't tried. But logo design, to me, is kind of a thing all it's own and I'm just not very good ... [ » ]