Assuming that your Theme:
- Uses the default comment-list markup, via
wp_list_comments()
, or
- 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.