Separating Trackbacks from Comments
Trackbacks are the messages displayed in the comments list whenever another blog links back to one of your posts. Many blogs disable trackbacks, but not all.
If you use trackbacks on your blog, it is best if they are not mixed with the comments. The comments are a conversation between between real people. Having machine-generated links in the middle of that will only serve to disrupt the conversations.
The method described here will lift out all of the trackbacks, and then display them as a numbered list after the list of comments is finished. Once you have this done, customizing the trackbacks to appear however you want them to is simple.
And thanks to Gary, the Trackbacks header will only appear if the post has a trackback to show.
NB - This method will only work for WordPress users. Sorry guys!
How To Separate the Trackbacks
Open comments.php, and search for the following line:
<?php foreach ($comments as $comment) : ?>
After it, paste the following:
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>
Now look for:
<?php endforeach; /* end for each comment */ ?>
And before it, paste:
<?php } else { $trackback = true; } /* End of is_comment statement */ ?>
That means that your list of comments will continue to display as normal, but without any trackbacks or pingbacks. Now we will add a second comments loop for the trackbacks.
Look for the following line:
<?php else : // this is displayed if there are no comments so far ?>
And before it, paste this: (The "Trackbacks" title line can be deleted if you don't want a heading to be shown)
<?php if ($trackback == true) { ?>
<h3>Trackbacks</h3>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type != 'comment') { ?>
<li><?php comment_author_link() ?></li>
<?php } ?>
<?php endforeach; ?>
</ol>
<?php } ?>
Of course, this is all only helpful if you actually use trackbacks, and there are some good reasons for either side of that debate. Do you use trackbacks on your blog? Why?
Enjoy this post? Get future updates sent to you for free! Join by email or RSS.
Other posts tagged with Clutter, Comments, Readers, Trackbacks, Usability.

7th January, 11:21 am GMT
Hi Michael,
About time some made a plugin for this (hint hint).
21st March, 9:06 pm GMT
I agree with you.
6th February, 8:23 pm GMT
tnx for the original tutorial, much apreciated!
10th February, 5:37 pm GMT
That worked like a charm - thanks for putting that together!
11th February, 4:06 am GMT
thx for this great tutorial, im gonna test it on my new blog,
11th February, 4:34 am GMT
fascinating and communicative, but would be suffering with something more on this topic?
16th February, 8:11 am GMT
Nice tips! thanks
16th February, 11:24 am GMT
This tutorial was exactly what I needed.
These small fixes here and there all around the blog can make such a big difference. This is exactly what I felt about the readability post also man! Wow! simple and thorough!
17th February, 8:48 am GMT
Thank you - nothing like a good trackback in the middle of a comment *conversation* - nice work.
24th February, 2:11 am GMT
thanks for this post.I now know what is trackback.
24th February, 5:18 am GMT
keep up the good work!
25th February, 1:29 am GMT
I don't know about trackbacks but now i know about trackbacks and there use.Thank you.
21st March, 12:29 pm GMT
i was looking for this
thank you so much
22nd March, 1:55 pm GMT
Thanks for this information rich tutorial.This is an asset for newbie bloggers
27th March, 3:04 pm GMT
I put up my first personal blog yesterday and found this really helpful. Thanks for sharing. Where does everybody get the time?
9th April, 9:32 pm GMT
Ive been looking to separate the two for a while now so thanks for creating a post on this subject.
20th April, 5:30 pm GMT
Very nice information. Thanks.
25th April, 12:02 pm GMT
Hello Michael,
first of all great explenation and great overall tutorial structure.
To answere your question, i do use trackbacks because i think it's a nice and very easy way to get to know the people browsing your site, reading your content and actually finding it helpful.
I do not have many trackbacks on my site but i will definitly change that in future
Again, great article!
11th May, 5:17 pm GMT
Thank you for putting up this tutorial. Works like a charm in my blog.
Raymond Selda’s Latest Post: Create A Tabbed Content Rotator Using jQuery
14th May, 5:31 am GMT
Wow. That worked perfectly! It actually makes the Trackbacks look a lot better on my blog
pchieng’s Latest Post: Lake Miramar Loop 5 Mile Run
18th May, 10:23 pm GMT
I can't find these code for my Thesis theme..
Another alternative, I must use the plugin.. :p
baloot’s Latest Post: Reezluz Goes Wild. Jom Baca Post Terpilih Di Blog Reezluv (Info Bisnes, Grafik dan Teknologi)
19th May, 12:09 pm GMT
lol - Good point - You don't get this level of control over your Thesis theme, or if you did, you'd lose the changes each time you upgraded.
23rd May, 10:21 pm GMT
Sorry, stupid question here:
Where is the comments.php file found?
I have found 2 comment.php (no "s") one in the includes and one in the admin, but I can't find comments.php (with the "s")
Neither of the comment.php files have the text I'm supposed to find.
Thanks for any help on this basic question!
Tom
24th May, 11:02 am GMT
Hi Tom,
It will be in wp-content/themes/your-theme-name . That's the folder that contains all your theme files. If you ever need to edit anything to do with your design, it will be in one of the folders in there!
You never edit the files in wp-admin or wp-includes because your changes would be overwritten when you next upgrade WordPress.
24th May, 2:29 pm GMT
Thanks Michael! I really appreciate the quick response!
25th May, 4:31 pm GMT
Welcome, good luck now!
3rd June, 12:49 pm GMT
nice! thanks
5th June, 4:54 pm GMT
Thanks, I used one of your trackbacks to work out how to put it before the comments
Ben’s Latest Post: Windows Update Won’t Work After Updating to Service Pack 3
15th June, 12:04 am GMT
Thanks for this, it helps wonders! Now to fix up the CSS.
Ivy´s last blog ..Beautiful British Columbia
18th June, 2:11 pm GMT
thank you very good ...
tatil´s last blog ..Çeşme Otel Yeni