How to Highlight Post Author Comments in WordPress?

Post Author comments in WordPress

When you talk about the World Wide Web, you are very much engrossed into the idea of the vast repository of information; the gateway into the storehouse of information is in technical terms a library of web pages that are scattered all over the vast network of interconnected computers. Today, one of the most widely named out term in the relation to websites and online pages is WordPress. Handling over 30 percent share of the hosting industry, the brand has started to become more or less a standard for newer ventures coming up online.

Now coming onto the crux of the writing, among all the different functionality that WordPress provides is the flexibility in how the site is viewed; as in this case highlighting the post author comments, which gives the author a louder voice in a set of conversation between several unknown fellow commenter. So here is how you can do this!

author comment

Highlighting post author comments in WordPress

The basic idea is to identify the email address of the commenter and to match it with that of the blog/website owner. if a match is found the slight design and color changes can help the author’s comments jump off the rest in a thread of comments.

Begin with editing the style.css file to add the ‘authcomment’ style.

Go to your theme’s root directory and open up the style.css file. Then simply add this bit of code at the end of the file.

.authorComment {
  background-color: #f3FF6C;
  font-weight: bold;

This is to prepare the look of the author’s comment with distinction to other comments. Once the above code is added to the stylesheet of our theme, we proceed to add a piece of supporting code to the comments.php file to make the couple of work. The following pieces of codes should replace the existing system.

So open up comments.php file and find the following line:

  • oddcomment; ?>” id=”comment

Replace with the following lines of code:

  • authorComment class from style.css if the user_id is 1 (admin) */ if ($post->post_author == $comment->user_id) { $oddcomment = “authorComment”; echo $oddcomment; } ?>” id=”comment

Once the codes are set in place, it is just a mouse click to refresh the website to see the changes up and running. So view your site and open up any of your old posts where you have commented on it along with others and you will find that the comments made by the author of a post is being highlighted with a different background color and the font is bold.

Checkout many more cool WordPress tips and tricks and make your blogging experience a pleasure.

About the author

Nitin Agarwal

A blogger, tech evangelist, YouTube creator, books lover, traveler, thinker, and believer of minimalist lifestyle.