Do you get a lot of Trackbacks and/or Comments on your Posts? Do you simply want to show Trackbacks at a different place or separately from the comments? Well, many of us want so.. Here’s a simple tutorial on How you can separate Trackbacks and Pingbacks from Comments.
Here we are going to play with the comments.php of your theme file. So make sure you back it up first.. so it may do no harm to your Blog or theme if you come across any error or do something wrong.
First things first.
Filtering out Trackbacks from Comments:
Open your comments.php in any text editor as Notepad, or WordPress’ Theme Editor will do too.
Locate for the following code:
<?php foreach ($comments as $comment) : ?>
Immediately after the above code, add this code:
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>
Now locate this code:
<?php endforeach; /* end for each comment */ ?>
And add this code just before the above code:
<?php } /* End of is_comment statement */ ?>
So, we just filtered out the Trackbacks from the comments. Now we have to create another loop to create trackbacks and pingbacks.
Creating loops for Trackbacks:
Just below this code:
<?php endforeach; /* end for each comment */ ?>
you will find this code :
<?php else : // this is displayed if there are no comments so far ?>
Just add this loop in between these two codes above:
<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() ?>
<?php } ?>
<?php endforeach; ?>
</ol>
You can play around, placing and styling as you want and your theme permits. Like changing the h3 heading to whatever suits you.





I wanted to try this on my blog but I couldn’t find the first line in my comments.php


Simon | Teenius´s last blog ..Ways To Find Topics For The Next Post
[Reply]
Enk. Reply:
December 6th, 2009 at 1:43 pm
That’s sad Simon.
If you have basic knowledge of HTML and/or PHP you should be able to figure out the loop of comments used in your theme and follow the tutorial.
Or feel free to share the comments.php, I’ll be more than happy to help!
[Reply]
Simon | Teenius Reply:
December 6th, 2009 at 6:43 pm
Awesome, I’ll chat to you about it on MSN

Simon | Teenius´s last blog ..A Brief Guide To Twitter Lists
[Reply]
Enk. Reply:
December 6th, 2009 at 8:02 pm
Yea sure !