Free Wordpress Blog Setup

How to Highlight Author’s Comments in WordPress

By Editorial Staff in Tutorials
How to Highlight Author’s Comments in WordPress

In blog posts that generate high amount of discussion, it often becomes hard for users to track the author’s comment. Specially when the discussion is heated, it is very interesting to see author’s thoughts. In this tutorial we will share one of the easiest and simplest way to highlight author’s comments in WordPress.

There are few plugins that does this job, but you don’t need a plugin to do it. Most snippets will target and try to find author’s email, but that actually slows your site down. Why not find author’s id and change the background color so it is easily pointed out.

First you need to open your style.css in your template folder and add the following:

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

Then you need to open your comments.php which is also located in your themes folder and find the code that looks some what like this:

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

Replace it with:

<li class="<?php if ($comment->user_id == 1) $oddcomment = "authorstyle"; echo $oddcomment; ?>"></li>

Note you must change 1 to the user id of the author. Once you do this, your blog comments will have a different background for the author’s comment compared to the rest.

Thanks to Matt Cutts for this tutorial.

Free Wordpress Blog Setup

Comments

5 Responses to “How to Highlight Author’s Comments in WordPress”
  1. Blake Imeson says:

    This method would fail for multi-author blogs right?

  2. janghuan says:

    In my wordpress version,I just need to add a exist class that the wordpress generates.It’s “comment-author-admin”.Maybe the class “bypostauthor” that wordpress generates also does work.

  3. nice tutorial, thank you

  4. Keith Davis says:

    Useful tip.
    When I read post comments, I tend to read the author’s comments on the assumption that what he says carries more authority.
    I’m OK with the CSS but never sure about the php.
    You may have enticed me to start messing with the php!

Share Your Opinions

Tell us what you're thinking...
and if you want a pic to show with your comment, then get gravatar!

Please make sure that you have read our Comment Policy.

Due to high volume of request from our readers, we are adding this feature that allows you to stay updated with this post's comments without having to participate in the discussion even though we would love your input as always. Don't worry we hate SPAM just as much as you do, so you will never receive any SPAM messages from our site and that's our promise to you.

Subscribe without commenting

Close Bar