Skip to main content Accessibility Feedback

How to remove trackbacks from your WordPress comments

Update: I’ve converted this snippet into a lightweight plugin called Remove Trackbacks.

For the last few years, I’ve been using some simple PHP magic to separate real comments from trackbacks in my comments section. A few weeks ago, I realized that trackbacks are by-and-large useless for the typical reader.

So, I decided to remove them. It’s as easy as adding this snippet of code, courtesy of Weblog Tools Collection, to your functions.php file…

add_filter('comments_array', 'filterTrackbacks', 0);
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 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;

There are other ways you could do this, but here’s why this approach rocks:

  1. You will still receive notifications if people link to your site on the web.
  2. It doesn’t just prevent new trackbacks. It also removes existing ones.
  3. Trackbacks aren’t just hidden, they’re removed from your comment count altogether.