How to Remove Pingbacks from the WordPress Recent Comments Widget

There's nothing more annoying than pingbacks displaying in the WordPress Recent Comments Widget. This week I set out on a quest to discover how to remove them from the widget. I'd already discovered how to have them not display on the comments page, but the widget is different altogether and the fix is so simple that I could kick myself. The sourcecode for the recent comments widget can be found in the wp-includes/default-widgets.php file. Search for the line that says:

and change it to

That's all it takes to filter the pingbacks out. Of course, you really don't want to mess around with the default WordPress widgets. Any WordPress update will overwrite your changes. What I did was copy the default Recent Comments source code and added to the bottom of my theme's functions.php. The new code is below. It has been modified so it does not conflict with the deafult widget. runs on the Genesis Framework

Genesis FrameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Check out the incredible features and the selection of designs. It's that simple—start using Genesis now!

Click here to download The Genesis Guide for Absolute Beginners (PDF - 1.4 MB)


  1. says

    If I just wanted to override just the constructor function in functions.php, as opposed to the all of WP_Widget_Recent_Comments, leaving the rest in default-widgets.php to possibly be recoded by a WP update, would that be possible? And if so, how? Thanks.

    I’m currently using an edit directly in default-widgets.php, understanding I’d need to add a new line after any update. But the other solution leaves the possibility of not incorporating potentially useful amendments.

    • says

      Sorry — confusion. It’s not the constructor function I was referring to. It was the filtering code:

      $comments = get_comments( apply_filters( ‘widget_comments_args’, array( … )

      Being that that is not a function, but an assignment, I suspect that a successful means of bringing that alone into functions.php may be less likely. But still hoping…

      • says

        Hi Rick,

        You’re right that you shouldn’t modify default widgets. I don’t know of any way to change the assignments and leave default widgets intact. You may have to do what I did—create your own widget. If you copy the default widget and modify it as I mentioned in the article above, you’ll be able to achieve what you need to do.


  2. Karl says

    Three years later your simple tweak still works like a charm. I can’t believe this issue hasn’t been fixed by WP, there are so many frustrated threads about it, but this was the only solution I found. Thank you.

  3. Vernon says

    Mahalo Victor for sharing this method of removing the pingbacks. I have been trying for several months to figure this out and your tip worked like a charm.

Leave a Reply

Your email address will not be published. Required fields are marked *