Disable trackbacks and pingbacks
Disable trackbacks and pingbacks in your comments section. Add this snippet to your functions.php. No need to modify the comments.php template. It will be stripped out with this filter functions.
/** * Snippet Name: Disable trackbacks and pingbacks * Snippet URL: https://wpcustoms.net/snippets/disable-trackbacks-pingbacks/ */ //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; } add_filter('comments_array', 'filterTrackbacks', 0); add_filter('the_posts', 'filterPostComments', 0);