The comment section is where your community thrives. It serves as a vital space for connection, conversation, and reader engagement.
As the author, your responses play a crucial role in this interaction. It’s important to ensure that your voice is easily identifiable to foster further discussion.
Emphasizing your comments gives them the recognition they deserve. This simple enhancement makes your discussion area appear more professional, organized, and inviting.
We believe that small design choices can significantly enhance user experience. This is one of the easiest and most impactful adjustments you can implement.
In this article, we will guide you through the process of highlighting the author’s comments in WordPress effortlessly.
Why Should You Highlight Author Comments in WordPress?
Comments are an excellent way to boost user engagement on your website. To encourage more comments on your articles, actively participating in discussions can be very effective.
For a new WordPress blog, you can easily respond to comments and engage in discussions with your readers. If you manage a multi-author blog, you can also encourage authors to assist with comment moderation.
Unfortunately, most WordPress themes do not differentiate between comments, displaying them all in the same style.
Casual readers might overlook the valuable insights provided by the author in the comments section.
By highlighting the author’s comments, you can ensure they are more visible and engaging for readers.
The main objective is to motivate new users to participate in the discussion and ultimately encourage them to subscribe to your newsletter or make a purchase.
Now, let’s explore how to easily highlight author comments in WordPress.
- Highlighting Author Comments in WordPress
- Highlighting Comments Based on User Role in WordPress
Highlighting Author Comments in WordPress
The simplest method to highlight comments made by the post author is to add custom CSS to your WordPress theme. This approach allows you to incorporate the necessary code and view a live preview of the changes on your site without needing to save them.
First, navigate to Appearance » Customize in the WordPress admin dashboard. This action will open the WordPress theme customizer, where you will see various options on the left and a live preview of your website.
Next, click on the ‘Additional CSS’ tab.
This will reveal a text area where you can input your custom CSS.
You will want to preview how the custom CSS appears when applied.
To do this, navigate to a blog post that includes comments from the author.
Scroll down to the comments section and enter the following custom CSS in the Custom CSS box on the left.
.bypostauthor { background-color: #e7f8fb;
}
You will immediately see the author comment change to reflect the custom CSS you provided.
So, how does this work?
WordPress automatically adds certain default CSS classes to various sections of your website, which are consistent across all WordPress themes.
In this example, we are using the .bypostauthor CSS class, which is assigned to all comments made by the post author.
Let’s enhance the appearance further by adding additional CSS styles. Here’s a sample code that introduces a small ‘Author’ label to the comments made by the post author and adds a border around the author’s avatar image.
.bypostauthor:before { content:"Author";
float:right;
background-color:#FF1100;
padding:5px;
font-size:small;
font-weight:bold;
color:#FFFFFF;
}
.bypostauthor .avatar {
border:1px dotted #FF1100;
}
This is how it appeared on our test site.
Highlighting Comments Based on User Roles in WordPress
Many WordPress blogs have team members dedicated to responding to comments. Popular sites often have the post author, administrators, and moderators engaging with comments to enhance user interaction.
How can you highlight a comment made by a team member who is not the original author of the post?
There is a simple solution to accomplish this. However, it requires adding custom code to your WordPress site. If you are unfamiliar with this process, check out our article on how to insert code snippets into WordPress.
To start, you need to insert the following code into your theme’s functions.php file or use a code snippets plugin:
if ( ! class_exists( 'WPB_Comment_Author_Role_Label' ) ) :
class WPB_Comment_Author_Role_Label {
public function __construct() {
add_filter( 'get_comment_author', array( $this, 'wpb_get_comment_author_role' ), 10, 3 );
add_filter( 'get_comment_author_link', array( $this, 'wpb_comment_author_role' ) );
} // Retrieve the comment author's role function wpb_get_comment_author_role($author, $comment_id, $comment) { $authoremail = get_comment_author_email( $comment); // Verify if the user is registered
if (email_exists($authoremail)) {
$commet_user_role = get_user_by( 'email', $authoremail );
$comment_user_role = $commet_user_role->roles[0];
// HTML output to display next to the comment author's name
$this->comment_user_role = ' Instead of modifying your theme’s functions.php file, we suggest using WPCode to add this code.
This plugin for code snippets allows you to safely and easily incorporate custom code into your WordPress site.
To begin, install and activate the free WPCode plugin. For assistance, refer to our guide on how to install a WordPress plugin.
Once the plugin is activated, navigate toCode Snippets » Add Snippetin your WordPress dashboard.
Next, hover over the ‘Add Your Custom Code (New Snippet)’ option and click the ‘Add Custom Snippet’ button.
Then, choose ‘PHP Snippet’ as the code type from the options displayed on the screen.
Now, you can enter a title for your snippet and paste the code from above into the ‘Code Preview’ box.
After that, simply switch the status from ‘Inactive’ to ‘Active’ and click the ‘Save Snippet’ button at the top of the page.
This code adds the user role label next to the comment author’s name. Here’s how it appears without any custom styling.
Let’s enhance the appearance by adding some custom CSS. Navigate toAppearance » Customizeand switch to the Additional CSS tab.
You can apply the following CSS to style the user role label in the comments.
.comment-author-label { padding: 5px; font-size: 14px; border-radius: 3px;
} .comment-author-label-editor { background-color:#efefef;
}
.comment-author-label-author {
background-color:#faeeee;
} .comment-author-label-contributor {
background-color:#f0faee; }
.comment-author-label-subscriber {
background-color:#eef5fa; } .comment-author-label-administrator { background-color:#fde9ff;
}
Here’s how it appeared on our test site. Feel free to adjust the code to fit your theme’s colors and design.
For further information, check out our article on adding user role labels to WordPress comments.
We hope this guide has helped you learn how to highlight author comments in WordPress. You might also be interested in our tutorial on highlighting new posts for returning visitors in WordPress and our top recommendations for the best author bio box plugins for WordPress.
If you enjoyed this article, please subscribe to our YouTube Channel for WordPress video tutorials. You can also connect with us on Twitter and Facebook.



