WordPress comes with a widget that allows you to display recent comments and replies to your blog posts. This widget can be added to your sidebar and is quite handy to show active engagement on your website.
However, by default, this widget shows author replies and comments as well as user comments. This is quite annoying. For example, if you wrote the post and are replying to your users comments, the recent comments widget displays your comments too.
Instead of switching to a different recent comments plugin, there is a way to remove the post author replies from the recent comments widget inherent to WordPress.
To Remove Author Replies
Add the following code to one of the following places:
- Your website’s functions.php file.
- Your own website specific plugin or “kitchen sink plugin” as I like to call them.
function wp_recent_comments_less_author( $array ) {
global $post; $array['user_id'] = !$post->post_author; return $array; }
add_action( 'widget_comments_args', 'wp_recent_comments_less_author' );
After adding the above code, author replies and comments will no longer appear on your website. Now you will not need to use another plugin to make your site seem more professional!
Exactly what I was looking for, your directions worked perfect, thanks.