Filtering Out Pingbacks From A WordPress.com-Hosted “Recent Comments” Box

If you self-host your WordPress blog, you can do whatever you want.  If your blog is hosted at WordPress.com, you’re very limited in what you can customize.

For instance, for years I have wanted to get rid of pingbacks from myself in the “Recent Comments” box on the pages.  When I link to older messages, the box ends up looking like this:

commentsI look like a monomaniacal self-commenter.  Like, eek.  So yesterday I spent most of the day googling around trying to find out how to stop this insanity.  And it turns out that this is something that users have requested from Automattic since (at least) 2009, but they just haven’t implemented it.

Even though it’s totally trivial.  On a self-hosted WordPress blog, it’s a one line change.

So my choice here is to either start self-hosting (and I don’t want to — I host enough stuff already), or to figure out a way to work around this weirdness.

WordPress.com offers a few handfuls of widgets.  One of them seemed promising — the “Text Widget”.  But although you can put HTML in there, there’s no way to update it automatically, or use an <iframe> to embed HTML dynamically.

Then I saw that there’s an RSS widget!  What if I were to download the comments feed from WordPress, filter out all pingbacks, and then create a new RSS feed based on that?

Presto!

rssNo more pingbacks!  However, the RSS feed only has the last ten comments, and virtually all of them were pingbacks (except for the two test comments I added while developing), so I’m still the only one there in that box.  But that should hopefully fix itself after a while.  🙂

(The script caches comments, so it should build up to a more meaningful feed after a while…)

The code is on Github, so feel free to use it if you’re also annoyed by the “Recent Comments” box. Two non-optimal things about using this way to list the comments: 1) No images are allowed in the RSS Widget on WordPress.com, so it looks kinda boring, and 2) WordPress.com caches the RSS for a while (an hour?), so it’s not updated immediately.

But it’s good enough for me, and I won’t have to start self-hosting (and stop paying Automattic money).

(My very first Python script!  Python seems rather inconsistent.  Hysterical raisins, I guess.)

One thought on “Filtering Out Pingbacks From A WordPress.com-Hosted “Recent Comments” Box”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s