Remove Pingbacks from Recent Comments Widget

If you display a Recent Comments Widget on your sidebar like most WordPress blogs do, you may want to prevent entries like Pingbacks from showing on the list. This would simplify the widget and only display actual Comments that are on your site. Most tutorials I’ve read suggests editing the default-widgets.php inside the wp-includes folder however, editing a core WordPress file is not good practice and is strongly discouraged. It is much safer to use the widget’s filter to make the necessary modifications.

  • 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_pingback_recent_comments( $array ) {
	$array['type'] = 'comment';
	return $array;
add_filter( 'widget_comments_args', 'ra_pingback_recent_comments' );

The image below shows the result. The Recent Comment Widget on the right only displays actual comments and not ping-backs.

Remove Pingbacks on WordPress Widget

How to Remove Author Comments from Recent Comments Widget

Share This Post


Add a Comment
  1. Thank you so much for providing this simple solution.

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. Add code here