WordPress - Separating Comments from Trackbacks and Pingbacks

I don’t know about you, but when I’m reading through comments and see a random link with text around it, it just feels out of place. At first I look at it and think “what the hell is that?” Then once I realize it is a pingback, I just move along. Don’t get me wrong though, I love pingbacks and trackbacks, they are what makes the blogosphere so great.

Just if only there were a way to separate those pingbacks and trackbacks from comments. Oh, wait! There is. The problem though, is that this will only work with a regular template. If you are using the plugin Brian’s Threaded Comments this won’t work. But, since I’m the “nerd that keeps on giving” I’ll set you in the right direction:

Do a search for this within your comments.php:
if($comment_type == 'comment') {
$GLOBALS['comment'] = &$comment;
write_comment($GLOBALS['comment']);
}

(it should be somewhere around line 137 if you didn’t make any changes)

Just after, add:
if($comment_type != 'comment') {
$backlinks = 'true';
}

(there should be another } after the code)

Right before:
<?php else : >
<p><?php _e('No comments yet.'); ?></p>

Add:
<?php
if($backlinks == 'true') {
echo '<h3>Backlinks</h3>';
echo '<ol>';
}
foreach ($comments as $comment) :
$comment_type = get_comment_type();
if($comment_type != 'comment') {
echo '<li>'.get_comment_author_link().'</li>';
}
endforeach;
if($backlinks == 'true') {
echo '</ol>';
}
?>

Of course, you can change <h3>Backlinks</h3> to whatever you want to call it.

This script will automatically add all the trackbacks and pingbacks after all the comments.

Add to Del.cio.us RSS Feed Add to Technorati Favorites Stumble It!
   www.sajithmr.com

Rate:
2.8

If you enjoyed this post, please consider subscribing to my full feed RSS.

Written: Feb 5, 2008
Tags: , , ,

Related Articles:
Trackbacks VS Pingbacks
WP Plugin: Brian’s Threaded Comments with Author Highlighted Comments
How to Write Great Content and Keep Visitors Interested
Howto: Manually Install SezWho
WordPress Themes


RSS feed

4 Comments »

Comment by no imageElite By Design (Who am I?)
2008-02-05 23:10:08

I think I will add this in soon. I agree that it can be frustrating to have pings in the middle of the comments, so thanks for this post! Stumbled.

Rate:
2.9
Comment by no imageGary R. Hess (Who am I?)
2008-02-06 12:31:40

Thanks for the stumble, Brian.

Rate:
2.9
 
 
2008-02-07 01:02:29

Hey Gary,

I want your opinion on this one….

Is it better to leave the trackback as a comment on the blog, or to delete the trackback?

I don’t mind the trackbacks from blogs that link to my post. But What I mainly concerned is from scrapers who scrap content and then link back to my blog post. Should I delete it? Ignore it? whats your take on this.

Here is a link to an example of a trackback that I am referring to. citimastercard.net/scammed-by-an-ebay-member/

-Jean Costa

Rate:
2.9
Comment by no imageGary R. Hess (Who am I?)
2008-02-07 01:45:50

Trackbacks don’t necessarily bring quality to your own blog, so if it is spam like a scraper, definitely delete it.

I let all non-spam trackbacks/pingbacks show. When you show the trackbacks/pingbacks, it is sort of an incentive. Some people, particularly those just starting out like to trackback/pingback to other blogs because it will show somewhere on the page and hope for a click through. It may also give more of an incentive to long-time members to link back because of this.

Rate:
2.9
 
 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.
Advertise on impNERD.com
Elite By Design WordPress Theme
1993 Honda Civic
Make money online
PoemofQuotes Blog