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 :

1 Comment

Add a Comment

Leave a Reply

Anything that resembles spam is deleted. Keyword names are also changed or deleted.

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

ronangelo © 2012 - 2016 Frontier Theme
css.php