• Skip to main content

Victor Font Consulting Group, LLC

The DEX Intranet Specialists

Call Us:

+1 919-604-5828

  • Home
  • Care Plans
    • Care Articles
    • Optional Subscriptions
  • Consultations
  • Products
    • Code Snippets
    • Public GitHub Repositories
    • Gist Snippets
    • Pastebin Snippets (Free)
    • Free Plugins
  • FAQs
  • Support
    • Graphic Design
  • Contact
    • Speakers
    • Portfolio
  • Resources
    • Free WordPress Video Training
    • Tutorials
    • Articles
    • Cybersecurity
    • EU Referral Network
You are here: Home / Code Snippet / How to Remove Pingbacks from the WordPress Recent Comments Widget

How to Remove Pingbacks from the WordPress Recent Comments Widget

By Victor M. Font Jr.
December 13, 20108 Comments

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:

$comments = get_comments( array( 'number' => $number, 'status' => 'approve' ) );

and change it to

$comments = get_comments( array( 'number' => $number, 'status' => 'approve', 'type' => 'comment' ) );

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 default widget.

  • 0share
  • Facebook0
  • Twitter0
  • Pinterest0
  • LinkedIn0
  • Print
  • SMS0

About Victor M. Font Jr.

Victor M. Font Jr. is an award winning author, entrepreneur, and Senior IT Executive. A Founding Board Member of the North Carolina Executive Roundtable, he has served on the Board of Advisors, of the North Carolina Technology Association, the International Institute of Business Analysis, Association of Information Technology Professionals, Toastmasters International, and the North Carolina Commission for Mental Health, Developmental Disabilities, and Substance Abuse Services. He is author of several books including The Ultimate Guide to the SDLC and Winning With WordPress Basics, and Cybersecurity.

Reader Interactions

VictorFont.com 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)

Leave a Reply Cancel reply

Your email address and website will not be published. Required fields are marked *
Posting a comment means that you agree with and accept our Comment & Product Review Policy

Comments

  1. Rick Gordon

    July 15, 2014 at 4:39 pm

    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.

    Reply
    • Rick Gordon

      July 15, 2014 at 5:02 pm

      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…

      Reply
      • Victor M. Font Jr.

        July 15, 2014 at 9:08 pm

        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.

        Victor

        Reply
  2. Karl

    March 21, 2014 at 5:49 am

    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.

    Reply
    • Victor M. Font Jr.

      July 15, 2014 at 9:06 pm

      Thanks Karl!

      Reply
  3. dzei

    June 21, 2011 at 9:27 pm

    Thanks, found the pingback article useful, it’s working great!

    Reply
  4. Mike Devarenne

    April 13, 2011 at 5:26 pm

    Thanks, this worked great! I used it to remove the comment author link by changing get_comment_author_link to get_comment_author.

    Reply
  5. Vernon

    January 26, 2011 at 1:58 am

    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.

    Reply

Call: +1 919-604-5828

Send us an E-mail

Accessibility Statement | Affiliate Marketing Disclosure | Capability Statement

Cookie Policy | Comment & Product Review Policy | Privacy Policy | Site Map | Terms & Conditions

Copyright © 2003–2023 Victor M. Font Jr.

Return to top of page