How to Distinguish Author Comments on Your Blog

Nov 29th, 07 | 10 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. [...]

Post your remark

Other Recent Articles

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 ... [ » ]

In Freelancing »

Family and Freelancing - The Ultimate Balancing Act

05/29/08
A couple weeks back FreelanceSwitch had an excellent article on how so many freelancers tend to disrespect their own time. It was an article I seriously needed to read, because I'm one of them. It's often not by choice, however. Due to parental demands or household responsibilities which must be ... [ » ]

In Productivity »

15 Apps/Services I’d Actually Pay For

05/17/08
Have you ever stopped to consider how heavily you rely on free or open source services? There are a number I use daily that improve/simplify my life or business, but until I saw Mark Ghosh's list of 15 websites or services he'd actually pay for (spurred by Ryan Spoon's post ... [ » ]