Separating Trackbacks & Pingbacks in WordPress 1.5 & Above

The code presented in this article is integrated in my freely downloadable theme, “Fauna“. In this theme the whole comment aspect has been cleaned up, codewise.

This code presented below works fine for WordPress 1.5 and above, and is derived from the “Classic” theme.

Since upgrading from WordPress 1.2, due to the way the new version handles trackbacks and pingbacks, I could no longer separate these from comments, as I used to do.

Here’s a way to do it that works in the new system.

The Code

To show separate trackbacks and pingbacks on a page in WordPress 1.5 or above, you can replace the code in the default [themename]/comments.php with the following:

43 thoughts on “Separating Trackbacks & Pingbacks in WordPress 1.5 & Above”

  1. Rob Mientjes says:

    You scared me there, with the font tags!

    Thanks for this handy code. I’m gonna compile a list of sweet shit for the new design, this one is so on it 🙂

  2. Joen says:

    You scared me there, with the font tags!

    The font tag. The JarJar Binks of HTML. The Comic Sans of Markup. Best_tag_ever.

    Oh but seriously, when I was posting this, I had some problems with how to present the code on the page. I ended up including a .PHPS file using the Code Viewer plugin. I should of course have included the .TXT file instead.

    Thanks for this handy code. I?m gonna compile a list of sweet shit for the new design, this one is so on it 🙂

    Point of note: If you’re starting anew with WP 1.5, (new DB), there’s no need to include the && !ereg("< pingback />", $comment->comment_content) && !ereg("< trackback />", $comment->comment_content part of the code (minus the space after the <'s). It is merely there to be backwards compatible. I should probably add this to the article.

  3. Michael says:

    Doesn’t the upgrade process automatically update the old pingback and trackback stuff in the db?

  4. Joen says:

    Doesn?t the upgrade process automatically update the old pingback and trackback stuff in the db?

    Uh… there’s an “update” process!? Ahem. I mean db-wise?

  5. Michael says:

    I think so… But I’m not sure though. Did you look? 🙂

  6. Joen says:

    Did you look?

    Ahem… well that’s the thing… no.

    But I learned some regular expressions 🙂

    I’ll check when I get home. Thanks, anyway.

  7. Cara says:

    Hi, just drop by to let you know that i use this in my website, for “Strayhorn” version.

    Thanks for providing the code.

  8. I have a client ( that requested separating comments from trackbacks and this (with a little tweaking) worked perfectly! 😀

    Thank you very much!

  9. Pingback: Standing Tall
  10. tai says:

    I’ve localized it and posted it on my blog below with the link to this page and the credit to you. As for localizing, actually I’ve jsut replace a few words, though. 😉


    Thanks again, Joen!

  11. Lorelle says:

    Is there an easy way to have the comments first and the trackbacks last? I never want to read the trackbacks on people’s articles because I want to know what people are commenting on first. So I think they should come first.

    And please put the text file link at the top of the code so we don’t grab the other stuff and have to mess with it before seeing the link. Or at least telling us. The alternating colors of the code on the page is really hard to see and I toitally missed the link until I saw the comment about it.


  12. Joen says:

    Hello Lorelle,

    I’m sorry you had a bad time here. Unfortunately this page suffered from a recent redesign I made, so the colours haven’t been the best. I’ll try and see what I can do, based on your suggestions.

    As for the actual code, I do believe that it is “enough” to select the entire part that starts with

    < ? // Begin Trackbacks ?>

    and ends with

    < ? // End Trackbacks ?>

    and move it down below the similar part for the comments. Let me know how it goes.

  13. Cyrris says:

    Excellent. I never thought to bother with anything like this, but my blog got it’s first couple of pingbacks the other day, and they looks awful inside the regular comment list.

    This works very well, thanks!

  14. Brian Bonner says:

    This is close to what I would like to do, but I want trackbacks on their own page and comments on their own page. It is not an issue yet, but once I start getting allot of trackbacks and comments it will not be functional as created. What were the designers thinking?

  15. Joen says:


    I have some upcoming code which makes it even easier to separate out track and pingbacks. There’s no reason why you shouldn’t be able to make that into two separate files.

  16. Brian Bonner says:

    Oh please post here when it is done! Thank you!

  17. Brian Bonner says:


    That was enough for me to make it do what I wanted!

  18. Brian Bonner says:

    For some reason pingbacks are not showing, if I change their designation to trackback they show up. what would be causing this to happen?

  19. Pingback: Definitely Maybe
  20. Pingback: ~ XIII
  21. Joen, thanks for the code – it worked like a charm.

    One further question, though… how do I split out the tallies of the comments from those of the trackbacks on the main page?

    For example, right now for each post it says “Permalink Comments(3)”

    How can I make it say “Permalink Trackbacks(1) Comments(2)”?

  22. Joen says:


    Another commentator was so kind and wrote a plugin to do just that: Smart Count.

  23. Joen, thanks for the smart count link. I was wondering if you could help me a little more with that (I know it’s not your plugin, but marcosmedia’s contact form was in Spanish).

    I got it and activated it. And I’m assuming that I’m supposed to put the php mm_comts and mm_track lines he notes in the index.php file, wherever I want the counts to appear. I did that, and technically it worked, but all I got were the number counts (gray color, not black) and no verbiage – such that it read “Permalink 02”

    How/where do I add the words “Comments” and “Trackbacks” as well as to make them links to the correct places (that is, so that they’ll pop down to the comment form or the trackbacks of a post) and to make the font black?

    I’m not a code expert by any means so I really appreciate your help and am glad there are folks out there who make these plugins.

  24. Joen says:

    Well, as you mention I haven’t tried the plugin. However, I think i know how you can do what you want to do.

    The place where you want to write “Trackbacks (x) Comments (x)”, I would guess that you’re using the builtin comments_popup_link right?

    Well, don’t. Instead do this:

    < a href="< ?php the_permalink() ?>#comments">Comments(< ?php smartcountfunction ?>)< /a>

    Etc. Get it?

  25. Yep, and it works perfectly! Thanks again!

  26. Nat says:

    Hello, thanks for the code. Is this the code you are still using wiht your current theme? i really like what you have going here.

  27. Joen says:


    The code has been optimized, cleaned up and merged with my Fauna theme. You can grab it there.

  28. Raw Carrot says:

    Thanks for the insight into how to separate the comments from the trackbacks. Very useful. Thanks again.

  29. Joen says:

    Brian (who posted here asking for email removed), while cleaning up spam i accidentally deleted yours too. Sorry about that, and sorry for all the spam you received. Somehow my countermeasures failed me.

  30. robert says:

    Is this the same plugin you have mentioned above ?

  31. Edited to remove as the bug has been fixed. Thanks.

Comments are closed.