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:
- comments.php modified to separate trackbacks & pingbacks
Please check out the trackbacks below to find ported / different versions.
- The Curse of Comic Sans
- Separating Trackbacks & Pingbacks in WordPress 1.5 & Above
- Worlds Largest Digital Photo
- No | January - Frost
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 :)
The
fonttag. 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.
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_contentpart 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.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?
I think so… But I’m not sure though. 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.
Hi, just drop by to let you know that i use this in my website, for “Strayhorn” version.
Thanks for providing the code.
I have a client (californiaconservative.org) that requested separating comments from trackbacks and this (with a little tweaking) worked perfectly! :D
Thank you very much!
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!
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.
Thanks.
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.
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!
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?
Brian,
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.
Oh please post here when it is done! Thank you!
Thanks!
That was enough for me to make it do what I wanted!
For some reason pingbacks are not showing, if I change their designation to trackback they show up. what would be causing this to happen?
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)”?
Dan,
Another commentator was so kind and wrote a plugin to do just that: Smart Count.
http://wp.marcosmedia.com.ar/plugins/smart-count/
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.
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_linkright?Well, don’t. Instead do this:
Etc. Get it?
Yep, and it works perfectly! Thanks again!
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.
Nat,
The code has been optimized, cleaned up and merged with my Fauna theme. You can grab it there.
http://www.noscope.com/fauna/
Thanks for the insight into how to separate the comments from the trackbacks. Very useful. Thanks again.
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.
Is this the same plugin you have mentioned above http://defmay.com/wordpress/plugins/smart-count ?
Edited to remove as the bug has been fixed. Thanks.