Back when WordPress 2.7 was released, the WordPress team introduced a completely revamped comment form that included integration of threaded comments into the core software, introducing some dramatic changes with how comments are handled.   Unfortunately, this change broke one of the most popular comment hacks, separating trackbacks from comments.

Since then, several people have stepped up and shared some great hacks for separating trackbacks from comment in WordPress 2.7 or newer blogs .  So far the best guide I’ve found came from Sivel.net, which can be viewed here.  Click over and follow those steps get everything separated.

Note: The above guide is only for people using WordPress 2.7 or newer installations.  For people using WordPress 2.6 or earlier, you’ll want to use this tutorial.

Once you’ve got the comments successfully separated from the trackbacks, there are a couple additional tweaks you may want to do to clean up how things look (it really depends on preference I suppose).   The first is to clean up your trackbacks/pingbacks by only displaying the title instead of an excerpt and everything else.   In order to do this, you’ll need to find the following code in your comments.php file:

<ol>
<?php wp_list_comments('type=pings'); ?>

Now replace that code with the following:

<ol>
<?php wp_list_comments('type=pings&callback=list_pings'); ?>

Lastly, you’ll need to add the following code to your functions.php file (which can be created if you don’t already have one):

<?php
function list_pings($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
?>
<li id="comment-<?php comment_ID(); ?>"><?php comment_author_link(); ?>
<?php } ?>

That should clean up the trackbacks/pingbacks section and you can also apply the same changes if you use a plugin to display tweetbacks.

The other thing you may want to do is fix the comment count to only show actual comments, filtering out the trackbacks/pingbacks which are included in your comment count by default.   Simply add the following code to your functions.php file (which again can be created if you don’t already have one):

<?php
add_filter('get_comments_number', 'comment_count', 0);
function comment_count( $count ) {
if ( ! is_admin() ) {
global $id;
$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
return count($comments_by_type['comment']);
} else {
return $count;
}
}
?>

So there you go.  Anyone have any other tips for cleaning up your comment form?

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Connect with Kyle on Twitter or Google+!

  1. ComputeLive says:

    Oh Thanks for the Tip Kyle.It was very simple..

  2. Love Graphics says:

    This was a nice tip, as I was having the same problem separating trackbacks from my blogs comments. Thank you.

  3. Ahmed says:

    Nice tuts thanks

  4. nicky says:

    Tested it wordpress 2.8.4…
    Works perfectly 5/5

    thanks

  5. Ashok says:

    Nice post. Still many people are using the old system wherein comments and trackbacks are not separated.

  6. Truck classifieds says:

    Awesome… exactly what i was looking for. but i have a question. how would i get the trackbacks to show just the title and not the excerpt?

  7. Sophie says:

    I am using wordpress 2.8 but this is a great post.

  8. Narga says:

    I wrote a similar post from a month ago, you can view once more with alternatively way:
    http://www.narga.net/89/separate-pings-from-comments-in-wordpress-v2-7/

  9. BadRussia says:

    Nice tips. Thanks :)

  10. Zack says:

    Thanks for this great tut, I’ve got one problem, after modification, my comment navigation disappeared, is this happen to you too?

    http://zacklive.com/separate-trackbacks-from-comments-in-wordpress-2-7/1022/

  11. Amy says:

    […] Separar los trackbacks de los comentarios en WordPress 2.7+ – WP Hacks. […]

  12. Oris WilliamsF1 says:

    i have a question. how would i get the trackbacks to show just the title and not the excerpt?

Trackbacks/Pingbacks »

  1. My Google Reader Shares – August 20, 2009 | OBannons Leap says:
  2. Wordpress Resources #1 | wpcrunchy says:
  3. 22 Latest Exceptional WordPress Hacks | EzTips | Wordpress Tips - Tutorials - Make Money Online says:
  4. 37?Wordpress???? | ??? says:
  5. WordPress Resources #1 « AsterHost says:
  6. mosaicllc.net/zombo: you can do anything with zombo says:

Tweetbacks »