How to highlight author comments in WordPress

Here's how to make your own comments background color different from the rest of the commenter's without using plugin.

First Step

Open your style.css or whatever the name of your css and add the following code

 
.authcomment
{
/*Use different color to match your theme*/
background-color: #B3FFCC !important;
}
 

Step Two

Open your comments.php and look for the line similar to this code since almost of the theme are derived from "Kubrick theme" which is the default theme of wordpress.

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

And replace it with the following code

 
<li class="<?php
/* Only use the .authcomment  class from style.css +
if the user_id is 1 (admin) */
if (1 == $comment->user_id) $oddcomment = "authcomment";
echo $oddcomment;
?>" id="comment-<?php comment_ID() ?>">
 

You are done! See my sample comment below.

Related Posts

Tags: wordpress tips

  • 3 Responses to “How to highlight author comments in WordPress”

    1. eligio says:

      @MP3 of course there’s a better way, you can use existing comment highlighter plugins. This tutorial show only how you can do it without plugins, and I think the simplier the better.

    2. I enjoyed reading the How to highlight author comments in WordPress post, although I did not think it was entirely the best approach … there are alternatives which would provide more positive results ..

    3. eligio says:

      comment code is courtesy of mattcutts

    Leave a Reply

    Recent Post

    Incoming search terms for the Article

    author, eclipse comments background color, free music videos, highlight-author-comments-wordpress, sample only, top 10 hosting