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.
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.
re thing, theres a few minor visual tweaks Id like to do. FINAL UPDATE: Thanks to Joen Ive managed the track/pingback thing I was talking about, although [...]
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!
Thank you very much!
WP ?????????????????????
WordPress ??????????????????????????????????????????????????????????????????????????????????…
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!
[...] ork after separating tracks and pings from comments. Hopefully. Separate the children with this – http://www.noscope.com/journal/2005/01/wp-separating-trackbacks-pingbacks
No Comments
»
No comments yet.
RSS feed fo [...]
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?
WordPress Plugin | Smart Count
WordPress, por defecto, no permite separar los comentarios de los trackbacks o referencias. Por lo tanto cuando utilizamos la funci
[...] Det er ogs? lykkedes mig at f? adskilt kommentarer og trackbacks med et hack (Ja ja Andreas p? det punkt er Moveable Type bedre
). Ogs? har har jeg foretaget nogle modifikationer for at f? det hele til at passe ind i det nye design. Trackbacks’ne kan nu findes nederst p? siderne. [...]
[...] This plugin can be used along with Joen’s modification of comments.php wich can be found here: http://www.noscope.com/journal/2005/01/wp-separating-trackbacks-pingbacks [...]
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!
[...] Sicuramente voglio rimettere in sesto la barra laterale. Inoltre ho messo un hack per i trackbacks nei replay dei commenti. Nei post principali aggiunger
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/
[...] something like that. not anymore? and these are links talking about the topic; http://www.noscope.com/journal/2005/01/wp-separating-trackbacks-pingbacks http://notes.mk-notes.com/tsp/ [...]
Thanks for the insight into how to separate the comments from the trackbacks. Very useful. Thanks again.
[...] Mit Hilfe des Codes von Noscope, ist es mir nun (endlich mal) gelungen, die Kommentare von den Track- & Pingbacks in der Anzeige unter den Beitr?gen zu trennen. LEs ist ‘ne ganz sch?ne Puzzelei geworden und ich wei? nicht so genau, ob ich den Code hier posten sollte (so als Hilfe f?r Andere)…Jetzt werden sie also getrennt unter “Feedback” am Ende der Beitr?ge aufgelistet und in den F?llen, wo es keine Kommentare bzw. TB/PB gibt, wird ein entsprechender Hinweis angezeigt. Schaut es euch einfach auf ein paar Seiten an… [...]
[...] Personalmente recomiendo usarlo junto con la modificación de comments.php del autor de noscope, Joen. Que permite mostrar el listado de los comentarios separados de los trackbacks. [...]
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.
[...] Im Rahmen der Blogdesign Tipps hab ich davon gesprochen, dass es eine Überlegung wert ist Kommentare von Track- & Pingbacks zu unterscheiden, wenn es an die Gestaltung der Kommentarregion geht. Lange hab ich erfolglos nach einem Plugin für eine derartige Trennung gesucht, letztlich konnte ich das Puzzle allerdings doch zusammensetzen. Nachdem ich mich durch einige Foren gefragt habe, bekam ich immer wieder ein und denselben Link zu einer, leider veralteten, Anleitung zur Lösung des Problems unter WordPress 1.3 bzw. 1.5. Heut früh bin ich dann über eine zwar spärlich kommentierte, aber funktionierende Variante für WordPress 2.0 gestoßen, die ich euch nicht vorenthalten will. Der folgende Code gehört in die comments.php: <?php if ($comments) : ?> <h3 id=”trackbacks”>Trackbacks/Pings</h3> <ol class=”commentlist”> <?php foreach ($comments as $comment) : ?> <?php if (get_comment_type() != “comment”){ ?> <li class=”<?php echo $oddcomment; ?> smaller” id=”comment-<?php comment_ID() ?>”> <cite><?php comment_author_link() ?></cite> <?php if ($comment->comment_approved ‘0′) : ?> <em>Your comment is awaiting moderation.</em> <?php endif; ?> <br /> <p class=”commentmetadata”><a href=”#comment-<?php comment_ID() ?>” title=”"><?php comment_date(‘F jS, Y’) ?> at <?php comment_time() ?></a> <?php edit_comment_link(‘e’,”,”); ?></p> </li> <?php /* Changes every other comment to a different class */ if (‘alt’ $oddcomment) $oddcomment = ‘’; else $oddcomment = ‘alt’; ?> <?php } ?> <?php endforeach; /* end for each comment */ ?> <h3 id=”comments”>Comments</h3> <?php foreach ($comments as $comment) : ?> <?php if (get_comment_type() “comment”){ ?> <li class=”<?php echo $oddcomment; ?>” id=”comment-<?php comment_ID() ?>”> <cite><?php comment_author_link() ?></cite> <?php if ($comment->comment_approved ‘0′) : ?> <em>Your comment is awaiting moderation.</em> <?php endif; ?> <br /> <p class=”commentmetadata”><a href=”#comment-<?php comment_ID() ?>” title=”"><?php comment_date(‘F jS, Y’) ?> at <?php comment_time() ?></a> <?php edit_comment_link(‘e’,”,”); ?></p> <?php comment_text() ?> </li> <?php /* Changes every other comment to a different class / if (‘alt’ == $oddcomment) $oddcomment = ‘’; else $oddcomment = ‘alt’; ?> <?php } ?> <?php endforeach; / end for each comment */ ?> Ich geb zu, das sieht auf den ersten Blick etwas verworren aus, wenn man sich allerdings dazu die Vorlage in der besagten comments.php anschaut kommt etwas Licht ins Dunkel. Alles, was man noch tun muss ist lediglich die Vorlage seiner Formatierung anzupassen. [...]
[...] This one was also fairly simple to implement. I spent a bit of time Googling for ways to do this and ended up finding a couple of different techniques but the code on all of them was really untidy (sorry). I’m a big fan of beauty in code, not because I’m a geek (although I am) but because I find it makes the code easier to understand and maintain. [...]
Is this the same plugin you have mentioned above http://defmay.com/wordpress/plugins/smart-count ?
[...] La kromprogramo de Eric MEYER por apartigi komentojn de reena?oj ne funkcias en eldono 2.1 de WordPress, do mi uzas programeton ene de la ?ablono (inspirita deblogero fare de Joen ASMUSSEN). [...]
[...] separating trackbacks from comments [...]
Edited to remove as the bug has been fixed. Thanks.
[...] noscope | Separating Trackbacks & Pingbacks in WordPress 1.5 (1.3) [...]