Remove Author from Recent Comments Widget

If your WordPress blog displays a Recent Comments widget on the sidebar or on any widget area, you may want to hide your own ( Post Author ) comments or replies from the list. There’s no need to edit core WordPress files. You can use the widget_comments_args filter.

  • Go to your Dashboard -> Appearance -> Editor
  • Select your functions.php ( it is recommended that you do this on a child theme )
  • Add the code below then click save.
function ra_recent_comments_less_author( $array ) {
	global $post;
	$array['user_id'] = !$post->post_author;
	return $array;
}
add_action( 'widget_comments_args', 'ra_recent_comments_less_author' );

On the image below, the Recent Comments widget on the right shows the post author’s comments or replies removed.

Remove Author Replies

How to Remove Pingbacks from Recent Comments Widget

Share This Post

3 Comments

Add a Comment
  1. Thanks for this. Very useful. And thank you for creating and offering Frontier — among the best, and I’ve been exploring WordPress themes since 2008. It’s unbelievably wonderful that it’s offered gratis. When I decided to change my long-time theme to a responsive them, I searched and searched, and I’m so happy I found Frontier. I’ve been using it for 2 blogs.
    Thanks also for the short easy-to-understand CSS tutorial and all your other posts.
    Wish you all good things!

  2. Useful post thanks. If you’re not familiar with PHP, another option is to use the Better Recent Comments free plugin. This has various options on what sort of information from your comments to display and you can use it to hide the author from the widget.

Leave a Reply

Please write your comments in english. I delete anything that even remotely resembles spam.

Note: When posting code, enclose it in pre and code tags.
e.g. <pre><code> Add code here </code></pre>