Trackbacks and comments in WordPress

Handling trackbacks and comments in WoedPressWhen you have written great content on your blog, there is a big chance that you’re getting both comments and trackbacks to your posts.

The standard configuration in WordPress handles both things as the same, where you could argue that it makes better sense to keep them separated.

In this post you’ll learn how to separate these two things.

The difference between Trackbacks and Comments

A trackback on a post is created, when a page on a external website is linking to a specific post on your blog. Displaying trackbacks on a post can be a way to show you readers that this post has a good credibility since other sites are using it as a source.

A comment is more like a conversation about the post. Users can ask questions, add additional information or express their attitude towards the post.

So trackbacks and comments are two very different things, and should therefore be kept separated from my point of view

Moving trackbacks

The approach in this post will be to remove the trackbacks from the comments and instead display the trackbacks after the comments.

1: Open comments.php from “Apperence->Plugins->editor”

2: Search for the following line in the file:

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

3: After it, paste the following PHP code:

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

4: Look further down the file for:

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

5: Before it, paste:

<?php } else { $trackback = true; } /* End of is_comment statement */ ?>

6: Look further down the file for the following line:

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

7: Before this line, paste this:

<?php if ($trackback == true) { ?>
<h3>Trackbacks</h3>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php $comm_type = get_comment_type(); ?>
<?php if($comm_type != 'comment') { ?>
<li><?php comment_author_link() ?></li>
<?php } ?>
<?php endforeach; ?>
</ol>
<?php } ?>

And that’s it. Now all trackbacks has been removed from the comments, and are displayed after the comments.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
fold-left fold-right
About the author
Jørgen Nicolaisen has been passionately interested in everything online since 1995. His experience is based on working with small hobby projects as well as high volume websites. Jørgen is currently focused on the PHP based programming framework - Codeigniter, and WordPress naturally

3 Replies to Trackbacks and comments in WordPress

  1. Joe says:

    “A trackback on a post is created, when a page on a external website is linking to a specific post on your blog.”

    Google indexing my link on that external page gives me a backlink. Unfortunately, many of these sites are never indexed.

    How do I create an RSS feed for trackbacks so I can send to RSS aggregators thereby increasing my chances of getting a backlink?

    Suggestions appreciated. Thanks, Joe

  2. jhnidk says:

    If you’re using wordpress, you can get inspiration in this post:
    http://tips4php.net/2010/05/create-custom-rss-feeds-in-wordpress/

  3. Joe says:

    I read that post first.

    Understand the concept & pretty sure it can be done. Not a coder so weak on the implementation side.

    I use a link building software called AMA and get tons of trackbacks. Unfortunately, most of them are never indexed by Google.

Comments are now closed for this article.