The main problem with the trackbacks/pingbacks are useless comments. Any spambot tools or person can spam your blogs and posts with useless linking. You can disable the trackbacks from wordpress dashboard but sometimes it is quite necessary to know “who links with your posts?” or “who plagiarise your posts ?”
The best option is to remove trackbacks/pingbacks from wordpress posts without disabling it from dashboard.
Why i remove trackbacks/pingbacks from my blog ?
Some posts like top 50 Twitter tracking and analytics Tools have more than 1600 re-tweets and 20+ trackback’s. Some of the trackback’s are from high authority blogs like huffingtonpost but few are from low authority rss ripper blogs which is merely 2-3 months old.
In order to protect the blog posts from spams i completely remove the trackbacks and pingbacks just from wordpress posts. I can still see the trackbacks on my dashboard but it is not coming on the blog posts.
There are some plugin’s to achieve the same but you can easily do this by adding a simple custom function in your functions.php file of wordpress theme.
Custom code to be added in functions.php
add_filter(‘the_posts’, ‘filterPostComments’, 0);
//Updates the comment number for posts with trackbacks
function filterPostComments($posts) {
foreach ($posts as $key => $p) {
if ($p->comment_count <= 0) { return $posts; }
$comments = get_approved_comments((int)$p->ID);
$comments = array_filter($comments, "stripTrackback");
$posts[$key]->comment_count = sizeof($comments);
}
return $posts;
}
//Updates the count for comments and trackbacks
function filterTrackbacks($comms) {
global $comments, $trackbacks;
$comments = array_filter($comms,"stripTrackback");
return $comments;
}
//Strips out trackbacks/pingbacks
function stripTrackback($var) {
if ($var->comment_type == ‘trackback’ || $var->comment_type == ‘pingback’) { return false; }
return true;
}
Comments
One response to “How to remove trackbacks/pingbacks from wordpress posts without disabling it from dashboard”