
Most wordpress themes out there (by default) combine both comments and trackbacks / pingbacks together and display under the same list. But why bother separating them? Simply to make things looks more organize so your blog commenters have a clearer picture what are the comments, what’s not. Doing it is not hard, but you need toe be using independent Wordpress blog (not the wordpress.com), provided with access to change comments.php. Prepare your favorite editor, and here we go.
You will be adding and editing you comments.php. So do a backup of that file before you start amending it.
Step 1
Look for:
<?php foreach ($comments as $comment) : ?>
Paste after:
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>
Step 2
Look for:
<?php endforeach; /* end for each comment */ ?>
Paste before:
<?php } else { $trackback = true; } /* End of is_comment statement */ ?>
Step 3
Look for:
<?php else : // this is displayed if there are no comments so far ?>
Paste before:
<?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 } ?>
That’s it. Update your blog and you’ll notice Trackbacks have been pulled out from comments and displayed underneath. If you want to display Trackbacks before comments. the easiest way is adding <div> to both and control the style via CSS. Have fun.
Read also: 40+ Most Wanted Wordpress Tricks and Hacks
Don't miss any post. Subscribe to Hongkiat's RSS feed now.
Related Contents |
Sponsors |
|
Posted by hongkiat in Wordpress, Wordpress Tips Tricks , at 06.08.08
Tags: comments, pingbacks, separate, trackbacks, Wordpress |
|

















Comments
Tan Kahong June 9th, 2008
This is a very good tips indeed. Thanks for sharing.
ReplySyahid A. June 9th, 2008
Good wordpress tips HK. The way you arrange the comments and trackbacks is really practical.
ReplyMat June 10th, 2008
Nice tips..Thanks a lot HK
Replyxiaomo June 19th, 2008
thank you~useful
ReplyJORGE July 29th, 2008
bueno
ReplyDavid Leggett August 14th, 2008
Appreciate the help mate :)
ReplyDownloader August 14th, 2008
Nice download. thanks
Reply