Separating Trackbacks from Comments in WordPress 2.7+
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?
You are reading Separating Trackbacks from Comments in WordPress 2.7+ © 2009 | WordPress Hacks | WordPress Directory | WordPress Forums | WordPress eBook
Enjoy writing about WordPress? Get your blog more exposure by joining the WordPress Hacks writing team!
|
|
|
|
|
|
Related posts:
- Become an Awesome WordPress Theme Developer The past year or so has seen a massive rise...
- Star Magazine WordPress Theme Star Magazine is a stylish magazine style premium WordPress theme...
- Send a large file with single click If you need to send large files to your friends...
Related posts brought to you by Yet Another Related Posts Plugin.
Recent Entries
- Determine the appropriate wordpress themes
- WordPress Revenue Secrets
- WordPress and Flash 10x Cookbook
- David Busch’s Quick Snap Guide to Photoblogging with WordPress: An Instant Start-Up Manual for Creating and Promoting Your Own Photoblog
- Building the Perfect Wordpress Blog
- Are You Using These Wordpress Plugins That Will Monetize Your Blog And Generate Web Site Traffic?
- Wordpress Technology ? the Best Way to Create a Multi Purpose Blog
- WordPress 100 Success Secrets – Start your Blog Today: WordPress Complete. Everything you need in easy steps to create your Blog and tell the world about your Passion
- Head First WordPress: A Brain-Friendly Guide to Creating Your Own Custom WordPress Blog
- Top Wordpress Plugins to Help You SEO Your Blog
Tags: blog free, blogs, blogspot com, build website, earn money, free themes, home business, how to make a website, internet business, make a website, make money, making money, mobile, online business, online make money, theme, Themes, web hosting, web site design, web templates, WP Theme