Article written

  • on 19.10.2007
  • at 11:30 AM
  • by derek

Simple Separation of Trackbacks and Comments

Finally, I did it. A much simpler way to separate Trackbacks and comments in Wordpress.

Three Simple Steps to Separate Trackback and Comments

1.) Access your comments.php file and locate the following code:

<?php foreach ($comments as $comment) : ?>

Immediately after the above code, you’ll want to place this code:

<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>

2.) Next, you’ll want to scroll down a little bit and locate the following code:

<?php endforeach; /* end for each comment */ ?>

Immediately before the above code, you’ll want to place this code:

<?php } /* End of is_comment statement */ ?>

This will filter out all of the trackbacks and pingbacks from your main comments loop. Now we need to create a second comments loop to display the trackbacks and pingbacks.

3.) Almost immediately below the code from step 2 you should find this code:

<?php else : // this is displayed if there are no comments so far ?>

Immediately before the above code, you’ll want to place this code:

<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>

You can adjust this code to display how you want to, including using a different header if you have a specific look for your header 3.

Dona, I know you’ll come up with your own version. Sorry, I can’t wait anymore hehehe.

Thanks to JohnTP and HackWordpress.com

Similar Post:

subscribe to comments RSS

There are 7 comments for this post

  1. donalyza says:

    haha, you finally did it.. :) no problem. its alright. don’t worry, i’ll be posting my own version soon.

  2. Eli says:

    nice… i always wanted to know that.. just like what abe and john chow is doing…

  3. [...] YuwonCedric had some tips on how to Separate Trackbacks and Comments [...]

  4. Jaypee says:

    Thanks for reminding me about this. I’ve had this in my to-do list for quite a while now but I always keep forgetting. :)

  5. derixc says:

    not a problem Jaypee! :-D

  6. [...] shares a simple way of separating trackbacks from comments. This can keep your blog organized and [...]

  7. Melina says:

    very interesting. i’m adding in RSS Reader

Please, feel free to post your own comment

* these are required fields