Remove Trackbacks from Comment Count in WordPress

Are you finding that your comment count in WordPress not the correct number? Adjusting the settings in the discussions screen still doesn’t fix it. Well, this little snippet of PHP added to your functions.php file should fix that.

Add this snipper to your functions.php file to tweak the comment count to not show trackbacks.

add_filter('get_comments_number', 'comment_count', 0);

function comment_count( $count ) {
    if ( ! is_admin() ) {
        global $id;
        $get_comments = get_comments('status=approve&post_id=' . $id);

        $comments_by_type = separate_comments($get_comments);

    return count($comments_by_type['comment']);
    } else {

        return $count;



Want to become a better web developer?

Join over 25,000 other developer & designers who get awesome links to the best news and articles each week delivered directly to their inbox.


  1. This thing is out of version. It is giving the following qouted error when a single item is displayed in wordpress.
    “Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\pubiza\wp-content\themes\point\functions.php on line 329”

    • Hi Zainulth,

      Thanks for pointing that out. I have now updated the snippet. If you have any problems please let me know.

This post currently has 2 responses. What do you think?

You can use basic HTML when posting code, please turn all < characters into &lt; or > into &gt;
If the code is multi-line, use <pre><code></code></pre>

Leave a Reply

Your email address will not be published. Required fields are marked *