WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Basically what I want is to have all comments posted by admins with different background color than the rest, so they're easily distinguishable.

I wasn't able to find any plugin that would do this though, and hacking it into the theme doesn't look very clean.

Any suggestions?

share|improve this question
do the admin comments have a unique css class? if yes, then all you need is some adaptation to style.css; if you don't know, please post a link to your site. – Michael Sep 17 '11 at 13:07
up vote 2 down vote accepted

By default WordPress already adds user/admin/post author specific CSS to comments with the following three elements.


So you can just add something like #comment-author-admin {background-color;blue;} to your stylesheet.

share|improve this answer

Assuming that your Theme:

  1. Uses the default comment-list markup, via wp_list_comments(), or
  2. Manually applies the <?php comment_class(); ?> template tag appropriately

...then all you need to do in order to style author comments is to target the CSS class .bypostauthor.

So, if, in your case, "author" = "admin", then you're all set.

However, if your site has multiple authors, and/or multiple admins, then that won't be sufficient.

Fortunately, the comment_class() template tag can accept an argument, used to pass additional classes (it is also passed through the comment_class filter, but that is more difficult to use in this case).

So, try something like this:

$additional_comment_classes = '';

if ( user_can( $comment->user_id, 'administrator' ) ) {
    $additional_comment_classes = ' byadmin';

Then, when you call <?php comment_class(); ?>, call it as <?php comment_class( $additional_comment_classes ); ?>

Note: you'll need to be using a callback to <?php wp_list_comments(); ?> in order to modify comment_class() in this manner. If you don't want to go that route, then you'll need to add the class via the comment_class filter.

share|improve this answer

Open your style.css on your template folder and add this:

.authorstyle { background-color: #B3FFCC !important; }

Now open your comments.php and find code that should look something like this:

<li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"></li>

and replace it with this code:

<li class="<?php if ($comment->user_id == /*Give Author ID here*/) $oddcomment = "authorstyle"; echo $oddcomment; ?>"></li>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.