How to Create a Custom Style for Admin Comments in WordPress

I noticed how on some WordPress blogs authors’ comments are styled differently from other people’s comments. I think this really makes it easier when users are scanning through your comments, looking for an actual moderator/author/admin’s response. Making your WordPress install style your author comments differently is quite a simple little coding modification where you only need to change a small piece of code in one file and add a style class to your CSS stylesheet.

This works only on WordPress 2.5.
Open up your themes comments.php file and look for line 27. Should look something like this…


  • id="comment-"> Says: comment_approved == '0') : ?> Your comment is awaiting moderation.
  • All you need to do is add is a little if statement to check if your author is an admin, and then a few more things. Copy the code below and paste it over the code above.

    
    user_id) { ?>
    
  • id="comment-">
  • id="comment-"> Says: comment_approved == '0') : ?> Your comment is awaiting moderation.
  • Then just add the “authorcomment” class to your CSS stylesheet and style it however you choose. Mine looks something like this.

    .authorcomment {
    background: url(images/bavota.png) no-repeat;
    float: left;
    width: 89px;
    height: 97px;
    }
    

    See below how my comments have the “B” logo on the left. You can add a background color or place the image differently or do whatever you choose to have a custom style for your author comments.

    Share this:

    Email
    Facebook
    Twitter
    Pinterest
    Pocket

    Premium Themes for WordPress

    Looking for an easy-to-use Premium Theme for WordPress? Check out Themes by bavotasan.com and have your site up and running in no time.

    Use this WordPress website builder to build powerful websites in no time for your or your clients.

    WordPress Hosting

    WP Engine – designed from the ground-up to support and enhance the workflow of web designers.

    Bluehost – providing quality web hosting solutions since 1996.

    About the author

    Picture of Luke Perrie

    Luke Perrie