Comments number without pingbacks and trackbacks

8

Posted in WordPress | February 20, 2010

Using this snippet you can get the total comments number for a post without pingbacks and trackbacks.

Open the functions.php file that you can find into your template folder, if you haven’t it you have to create it. After this, add this code at the bottom of file:

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;
	}
}
add_filter('get_comments_number', 'comment_count', 0);