Skip to content

Instantly share code, notes, and snippets.

@jimmitchell
Last active July 31, 2016 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimmitchell/456c5d123354dfbdc305 to your computer and use it in GitHub Desktop.
Save jimmitchell/456c5d123354dfbdc305 to your computer and use it in GitHub Desktop.
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
// Exclude pingbacks from comment count
// change "slug" to your theme's domain
function slug_comment_count( $count ) {
global $id;
$comment_count = 0;
$comments = get_approved_comments( $id );
foreach ( $comments as $comment ) {
if ( $comment->comment_type === '' ) {
$comment_count++;
}
}
return $comment_count;
}
add_filter( 'get_comments_number', 'slug_comment_count', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment