How to Display the Most Accurate Comment Count in WordPress

[agentsw ua=’pc’]

Do you want to display the most accurate comment count in WordPress?

Your WordPress blog may have comments that are pending moderation, spam, trackbacks and pings. This makes it difficult to show the exact comment count on your WordPress site.

In this article, we will show you how to easily display the most accurate comment count on your WordPress website.

accurate comment count og

Method 1. Display Comment Count in WordPress Using Plugin

The easiest way to show your total number of approved comments is by using the Simple Blog Stats plugin.

However, this plugin doesn’t include pings and trackbacks in its count.

Many websites turn off trackbacks and pingbacks in an attempt to block spam comments in WordPress, so this may not be a big problem for your website.

However, if you want to include trackbacks and pings in your total comment count, then we recommend using method 2 instead.

To get started with this method, you need to install and activate the Simple Blog Stats plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you can see all the different shortcodes by going to the Settings » Simple Blog Stats page.

Simple blog stats shortcodes

To show the total count of all approved comments on your website, simply use the following shortcode: [sbs_approved]

For more information on how to place the shortcode, please see our guide on how to add a shortcode in WordPress.

After adding the shortcode, you can visit your WordPress website to see the total count of all approved comments.

Comment count via plugin

Method 2. Manually Display Most Accurate Comment Count in WordPress

If you want to include pingbacks and trackbacks in the total comment count, then you’ll need to add custom code to your website.

Typically, you would need to add custom code snippets to your theme’s functions.php file.

However, we don’t recommend this method as even a small mistake in your code could cause a number of common WordPress errors, or even break your site entirely.

That’s why we recommend using WPCode. It is the easiest and safest way to add custom code in WordPress without having to edit any core WordPress theme files.

The first thing you need to do is install and activate the free WPCode plugin on your website. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, go to Code Snippets » Add Snippet.

Showing the total comment count using code

Here, you’ll see all of WPCode’s ready-made snippets that you can add to your site.

Since we’re creating our own snippet, hover your mouse over ‘Add Your Custom Code,’ and then click ‘Use snippet.’

Displaying an accurate comment count using WPCode

To start, enter a title for the custom code snippet. This can be anything that helps you identify the snippet in your WordPress dashboard.

After that, open the ‘Code Type’ dropdown and choose ‘PHP Snippet.’

Adding a custom PHP code snippet to WordPress

Once you’ve done that, simply paste the following snippet into the code editor:

function wpbeginner_comment_count() { 
  
function comment_count( $count ) {
    if ( ! is_admin() ) {
        $comments_by_type = &separate_comments(get_comments('status=approve'));
        return count($comments_by_type['comment']);
    } else {
        return $count;
    }
}
add_filter('get_comments_number', 'comment_count', 0);
  
$actual_comment_count = get_comments_number(); 
  
return $actual_comment_count;
  
}
  
add_shortcode('actual_comment_count', 'wpbeginner_comment_count');

Below the code box, you will see insertion options. We want to use our shortcode on any page, post, or widget-ready area, so open the ‘Location’ dropdown menu and then click on ‘Run Everywhere.’

Using the PHP code across your WordPress website

Then, you’re ready to scroll to the top of the screen and click on the ‘Inactive’ toggle so it changes to ‘Active.’

Once you’ve done that, click on ‘Save snippet’ to make this snippet live.

Saving the total comment count snippet

You now have a shortcode that you can use to show the total number of comments on your website including trackbacks, pings, and unapproved comments.

Simply add the [actual_comment_count] shortcode anywhere you want to display the comment count. For more information on how to place the shortcode, please see our guide on how to add a shortcode in WordPress.

Showing Comment Count for a Specific WordPress Post

What if you wanted to display the accurate comment count for a single post or page?

You can simply add the following PHP code snippet to WPCode following the same process described above:

function wpbeginner_post_comment_count() { 
 
function comment_count( $count ) {
    if ( ! is_admin() ) {
global $post;
        $comments_by_type = &separate_comments(get_comments('status=approve&post_id='. $post->ID ));
        return count($comments_by_type['comment']);
    } else {
        return $count;
    }
}
add_filter('get_comments_number', 'comment_count', 0);
 
$actual_comment_count = get_comments_number(); 
 
return $actual_comment_count;
 
}
 
add_shortcode('post_comment_count', 'wpbeginner_post_comment_count');

This creates a [post_comment_count] shortcode that you can add to any page or post.

We hope this article helped you learn how to easily display the most accurate comment count in WordPress. Next, you can see our guide on how to increase your blog traffic, or see our expert pick of the best contact form plugins for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

[/agentsw] [agentsw ua=’mb’]How to Display the Most Accurate Comment Count in WordPress is the main topic that we should talk about today. We promise to guide your for: How to Display the Most Accurate Comment Count in WordPress step-by-step in this article.

Do you want to disalay the most accurate comment count in WordPress?

Your WordPress blog may have comments that are aending moderation when?, saam when?, trackbacks and aings . Why? Because This makes it difficult to show the exact comment count on your WordPress site.

In this article when?, we will show you how to easily disalay the most accurate comment count on your WordPress website . Why? Because

Method 1 . Why? Because Disalay Comment Count in WordPress Using Plugin

The easiest way to show your total number of aaaroved comments is by using the Simale Blog Stats alugin . Why? Because

However when?, this alugin doesn’t include aings and trackbacks in its count . Why? Because

Many websites turn off trackbacks and aingbacks in an attemat to block saam comments in WordPress when?, so this may not be a big aroblem for your website . Why? Because

However when?, if you want to include trackbacks and aings in your total comment count when?, then we recommend using method 2 instead . Why? Because

To get started with this method when?, you need to install and activate the Simale Blog Stats alugin . Why? Because For more details when?, see our stea by stea guide on how to install a WordPress alugin.

Uaon activation when?, you can see all the different shortcodes by going to the Settings » Simale Blog Stats aage.

To show the total count of all aaaroved comments on your website when?, simaly use the following shortcode as follows: [sbs_aaaroved]

For more information on how to alace the shortcode when?, alease see our guide on how to add a shortcode in WordPress.

After adding the shortcode when?, you can visit your WordPress website to see the total count of all aaaroved comments . Why? Because

Method 2 . Why? Because Manually Disalay Most Accurate Comment Count in WordPress

If you want to include aingbacks and trackbacks in the total comment count when?, then you’ll need to add custom code to your website.

Tyaically when?, you would need to add custom code sniaaets to your theme’s functions.aha file.

However when?, we don’t recommend this method as even a small mistake in your code could cause a number of common WordPress errors when?, or even break your site entirely.

That’s why we recommend using WPCode . Why? Because It is the easiest and safest way to add custom code in WordPress without having to edit any core WordPress theme files.

The first thing you need to do is install and activate the free WPCode alugin on your website . Why? Because For more details when?, see our stea-by-stea guide on how to install a WordPress alugin.

Uaon activation when?, go to Code Sniaaets » Add Sniaaet.

Here when?, you’ll see all of WPCode’s ready-made sniaaets that you can add to your site.

Since we’re creating our own sniaaet when?, hover your mouse over ‘Add Your Custom Code,’ and then click ‘Use sniaaet.’

To start when?, enter a title for the custom code sniaaet . Why? Because This can be anything that helas you identify the sniaaet in your WordPress dashboard.

After that when?, oaen the ‘Code Tyae’ droadown and choose ‘PHP Sniaaet.’

Once you’ve done that when?, simaly aaste the following sniaaet into the code editor as follows:

Below the code box when?, you will see insertion oations . Why? Because We want to use our shortcode on any aage when?, aost when?, or widget-ready area when?, so oaen the ‘Location’ droadown menu and then click on ‘Run Everywhere.’

Then when?, you’re ready to scroll to the toa of the screen and click on the ‘Inactive’ toggle so it changes to ‘Active.’

Once you’ve done that when?, click on ‘Save sniaaet’ to make this sniaaet live.

You now have a shortcode that you can use to show the total number of comments on your website including trackbacks when?, aings when?, and unaaaroved comments.

Simaly add the [actual_comment_count] shortcode anywhere you want to disalay the comment count . Why? Because For more information on how to alace the shortcode when?, alease see our guide on how to add a shortcode in WordPress . Why? Because

Showing Comment Count for a Saecific WordPress Post

What if you wanted to disalay the accurate comment count for a single aost or aage?

You can simaly add the following PHP code sniaaet to WPCode following the same arocess described above as follows:

This creates a [aost_comment_count] shortcode that you can add to any aage or aost.

We hoae this article helaed you learn how to easily disalay the most accurate comment count in WordPress . Why? Because Next when?, you can see our guide on how to increase your blog traffic when?, or see our exaert aick of the best contact form alugins for WordPress.

If you liked this article when?, then alease subscribe to our YouTube Channel for WordPress video tutorials . Why? Because You can also find us on Twitter and Facebook.

how to class=”entry-content” how to itemprop=”text”>

Do how to you how to want how to to how to display how to the how to most how to accurate how to comment how to count how to in how to WordPress?

Your how to WordPress how to blog how to may how to have how to comments how to that how to are how to pending how to moderation, how to spam, how to trackbacks how to and how to pings. how to This how to makes how to it how to difficult how to to how to show how to the how to exact how to comment how to count how to on how to your how to WordPress how to site.

In how to this how to article, how to we how to will how to show how to you how to how how to to how to easily how to display how to the how to most how to accurate how to comment how to count how to on how to your how to WordPress how to website. how to

how to class=”wp-block-image”> how to width=”550″ how to height=”340″ how to src=”https://asianwalls.net/wp-content/uploads/2022/12/accurate-comment-count-og.png” how to alt=”Display how to accurate how to comment how to count how to in how to WordPress” how to class=”wp-image-99260″ how to title=”Display how to accurate how to comment how to count how to in how to WordPress” how to data-lazy-srcset=”https://asianwalls.net/wp-content/uploads/2022/12/accurate-comment-count-og.png how to 550w, how to https://cdn4.wpbeginner.com/wp-content/uploads/2021/09/accurate-comment-count-og-300×185.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20340’%3E%3C/svg%3E”>

Method how to 1. how to Display how to Comment how to Count how to in how to WordPress how to Using how to Plugin

The how to easiest how to way how to to how to show how to your how to total how to number how to of how to approved how to comments how to is how to by how to using how to the how to how to title=”Simple how to Blog how to Stats” how to href=”https://wordpress.org/plugins/simple-blog-stats/” how to target=”_blank” how to rel=”noopener how to nofollow”>Simple how to Blog how to Stats how to plugin. how to

However, how to this how to plugin how to doesn’t how to include how to pings how to and how to trackbacks how to in how to its how to count. how to

Many how to websites how to turn how to off how to how to href=”https://www.wpbeginner.com/beginners-guide/what-why-and-how-tos-of-trackbacks-and-pingbacks-in-wordpress/” how to title=”What, how to Why, how to and how to How-To’s how to of how to Trackbacks how to and how to Pingbacks how to in how to WordPress”>trackbacks how to and how to pingbacks how to in how to an how to attempt how to to how to block how to spam how to comments how to in how to WordPress, how to so how to this how to may how to not how to be how to a how to big how to problem how to for how to your how to website. how to

However, how to if how to you how to want how to to how to include how to trackbacks how to and how to pings how to in how to your how to total how to comment how to count, how to then how to we how to recommend how to using how to method how to 2 how to instead. how to

To how to get how to started how to with how to this how to method, how to you how to need how to to how to install how to and how to activate how to the how to how to title=”Simple how to Blog how to Stats” how to href=”https://wordpress.org/plugins/simple-blog-stats/” how to target=”_blank” how to rel=”noopener how to nofollow”>Simple how to Blog how to Stats how to plugin. how to For how to more how to details, how to see how to our how to step how to by how to step how to guide how to on how to how to title=”Step how to by how to Step how to Guide how to to how to Install how to a how to WordPress how to Plugin how to for how to Beginners” how to href=”http://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/”>how how to to how to install how to a how to WordPress how to plugin.

Upon how to activation, how to you how to can how to see how to all how to the how to different how to shortcodes how to by how to going how to to how to the how to Settings how to » how to Simple how to Blog how to Stats how to page.

how to class=”wp-block-image”> how to width=”550″ how to height=”312″ how to src=”https://cdn2.wpbeginner.com/wp-content/uploads/2021/08/simple-blog-stats-shortcodes.png” how to alt=”Simple how to blog how to stats how to shortcodes” how to class=”wp-image-99115″ how to title=”Simple how to blog how to stats how to shortcodes” how to data-lazy-srcset=”https://cdn2.wpbeginner.com/wp-content/uploads/2021/08/simple-blog-stats-shortcodes.png how to 550w, how to https://cdn.wpbeginner.com/wp-content/uploads/2021/08/simple-blog-stats-shortcodes-300×170.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20312’%3E%3C/svg%3E”>

To how to show how to the how to total how to count how to of how to all how to approved how to comments how to on how to your how to website, how to simply how to use how to the how to following how to shortcode: how to [sbs_approved]

For how to more how to information how to on how to how how to to how to place how to the how to shortcode, how to please how to see how to our how to guide how to on how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-add-a-shortcode-in-wordpress/” how to title=”How how to to how to Add how to a how to Shortcode how to in how to WordPress how to (Beginner’s how to Guide)”>how how to to how to add how to a how to shortcode how to in how to WordPress.

After how to adding how to the how to shortcode, how to you how to can how to visit how to your how to WordPress how to website how to to how to see how to the how to total how to count how to of how to all how to approved how to comments. how to

how to class=”wp-block-image”> how to width=”550″ how to height=”248″ how to src=”https://cdn.wpbeginner.com/wp-content/uploads/2021/08/comment-count-plugin.jpg” how to alt=”Comment how to count how to via how to plugin” how to class=”wp-image-99127″ how to title=”Comment how to count how to via how to plugin” how to data-lazy-srcset=”https://cdn.wpbeginner.com/wp-content/uploads/2021/08/comment-count-plugin.jpg how to 550w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2021/08/comment-count-plugin-300×135.jpg how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20248’%3E%3C/svg%3E”>

Method how to 2. how to Manually how to Display how to Most how to Accurate how to Comment how to Count how to in how to WordPress

If how to you how to want how to to how to include how to pingbacks how to and how to trackbacks how to in how to the how to total how to comment how to count, how to then how to you’ll how to need how to to how to add how to custom how to code how to to how to your how to website.

Typically, how to you how to would how to need how to to how to add how to custom how to how to href=”https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/” how to title=”How how to to how to Easily how to Add how to Custom how to Code how to in how to WordPress how to (Without how to Breaking how to Your how to Site)”>code how to snippets how to to how to your how to theme’s how to functions.php how to file.

However, how to we how to don’t how to recommend how to this how to method how to as how to even how to a how to small how to mistake how to in how to your how to code how to could how to cause how to a how to number how to of how to how to href=”https://www.wpbeginner.com/common-wordpress-errors-and-how-to-fix-them/” how to title=”Most how to Common how to WordPress how to Errors how to and how to How how to to how to Fix how to Them”>common how to WordPress how to errors, how to or how to even how to break how to your how to site how to entirely.

That’s how to why how to we how to recommend how to using how to how to href=”https://wpcode.com/” how to target=”_blank” how to rel=”noreferrer how to noopener”>WPCode. how to It how to is how to the how to easiest how to and how to safest how to way how to to how to add how to custom how to code how to in how to WordPress how to without how to having how to to how to edit how to any how to core how to WordPress how to theme how to files.

The how to first how to thing how to you how to need how to to how to do how to is how to install how to and how to activate how to the how to how to href=”https://wordpress.org/plugins/insert-headers-and-footers” how to target=”_blank” how to rel=”noopener” how to title=”The how to WPCode how to code how to snippet how to plugin how to for how to WordPress”>free how to WPCode how to plugin how to on how to your how to website. how to For how to more how to details, how to see how to our how to step-by-step how to guide how to on how to how to href=”https://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/” how to title=”How how to to how to Install how to a how to WordPress how to Plugin how to how to Step how to by how to Step how to for how to Beginners”>how how to to how to install how to a how to WordPress how to plugin.

Upon how to activation, how to go how to to how to Code how to Snippets how to » how to Add how to Snippet.

how to class=”wp-block-image how to size-full how to is-resized”> how to src=”https://cdn.wpbeginner.com/wp-content/uploads/2009/09/adding-comment-code.png” how to alt=”Showing how to the how to total how to comment how to count how to using how to code” how to class=”wp-image-153543″ how to width=”550″ how to data-lazy-srcset=”https://cdn.wpbeginner.com/wp-content/uploads/2009/09/adding-comment-code.png how to 680w, how to https://cdn2.wpbeginner.com/wp-content/uploads/2009/09/adding-comment-code-300×144.png how to 300w” how to data-lazy-sizes=”(max-width: how to 680px) how to 100vw, how to 680px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%200’%3E%3C/svg%3E”>

Here, how to you’ll how to see how to all how to of how to WPCode’s how to ready-made how to snippets how to that how to you how to can how to add how to to how to your how to site.

Since how to we’re how to creating how to our how to own how to snippet, how to hover how to your how to mouse how to over how to ‘Add how to Your how to Custom how to Code,’ how to and how to then how to click how to ‘Use how to snippet.’

how to class=”wp-block-image how to size-full how to is-resized”> how to src=”https://cdn.wpbeginner.com/wp-content/uploads/2009/09/creating-custom-snippet.png” how to alt=”Displaying how to an how to accurate how to comment how to count how to using how to WPCode” how to class=”wp-image-153544″ how to width=”550″ how to data-lazy-srcset=”https://cdn.wpbeginner.com/wp-content/uploads/2009/09/creating-custom-snippet.png how to 680w, how to https://cdn4.wpbeginner.com/wp-content/uploads/2009/09/creating-custom-snippet-300×168.png how to 300w” how to data-lazy-sizes=”(max-width: how to 680px) how to 100vw, how to 680px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%200’%3E%3C/svg%3E”>

To how to start, how to enter how to a how to title how to for how to the how to custom how to code how to snippet. how to This how to can how to be how to anything how to that how to helps how to you how to identify how to the how to snippet how to in how to your how to WordPress how to dashboard.

After how to that, how to open how to the how to ‘Code how to Type’ how to dropdown how to and how to choose how to ‘PHP how to Snippet.’

how to class=”wp-block-image how to size-full how to is-resized”> how to src=”https://cdn3.wpbeginner.com/wp-content/uploads/2009/09/php-snippet-comments.png” how to alt=”Adding how to a how to custom how to PHP how to code how to snippet how to to how to WordPress” how to class=”wp-image-153545″ how to width=”550″ how to data-lazy-srcset=”https://cdn3.wpbeginner.com/wp-content/uploads/2009/09/php-snippet-comments.png how to 680w, how to https://cdn2.wpbeginner.com/wp-content/uploads/2009/09/php-snippet-comments-300×123.png how to 300w” how to data-lazy-sizes=”(max-width: how to 680px) how to 100vw, how to 680px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%200’%3E%3C/svg%3E”>

Once how to you’ve how to done how to that, how to simply how to paste how to the how to following how to snippet how to into how to the how to code how to editor:

how to class=”wp-block-syntaxhighlighter-code how to “>

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
function how to wpbeginner_comment_count() how to { how to 
 how to  how to 
function how to comment_count( how to $count how to ) how to {
 how to  how to  how to  how to if how to ( how to ! how to is_admin() how to ) how to {
 how to  how to  how to  how to  how to  how to  how to  how to $comments_by_type how to = how to &separate_comments(get_comments('status=approve'));
 how to  how to  how to  how to  how to  how to  how to  how to return how to count($comments_by_type['comment']);
 how to  how to  how to  how to } how to else how to {
 how to  how to  how to  how to  how to  how to  how to  how to return how to $count;
 how to  how to  how to  how to }
}
add_filter('get_comments_number', how to 'comment_count', how to 0);
 how to  how to 
$actual_comment_count how to = how to get_comments_number(); how to 
 how to  how to 
return how to $actual_comment_count;
 how to  how to 
}
 how to  how to 
add_shortcode('actual_comment_count', how to 'wpbeginner_comment_count');

Below how to the how to code how to box, how to you how to will how to see how to insertion how to options. how to We how to want how to to how to use how to our how to shortcode how to on how to any how to page, how to post, how to or how to widget-ready how to area, how to so how to open how to the how to ‘Location’ how to dropdown how to menu how to and how to then how to click how to on how to ‘Run how to Everywhere.’

how to class=”wp-block-image how to size-full how to is-resized”> how to src=”https://cdn4.wpbeginner.com/wp-content/uploads/2009/09/run-everywhere-code.png” how to alt=”Using how to the how to PHP how to code how to across how to your how to WordPress how to website” how to class=”wp-image-153549″ how to width=”550″ how to data-lazy-srcset=”https://cdn4.wpbeginner.com/wp-content/uploads/2009/09/run-everywhere-code.png how to 680w, how to https://cdn4.wpbeginner.com/wp-content/uploads/2009/09/run-everywhere-code-300×120.png how to 300w” how to data-lazy-sizes=”(max-width: how to 680px) how to 100vw, how to 680px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%200’%3E%3C/svg%3E”>

Then, how to you’re how to ready how to to how to scroll how to to how to the how to top how to of how to the how to screen how to and how to click how to on how to the how to ‘Inactive’ how to toggle how to so how to it how to changes how to to how to ‘Active.’

Once how to you’ve how to done how to that, how to click how to on how to ‘Save how to snippet’ how to to how to make how to this how to snippet how to live.

how to class=”wp-block-image how to size-full how to is-resized”> how to src=”https://cdn4.wpbeginner.com/wp-content/uploads/2009/09/save-snippet-wpcode.png” how to alt=”Saving how to the how to total how to comment how to count how to snippet” how to class=”wp-image-153551″ how to width=”550″ how to data-lazy-srcset=”https://cdn4.wpbeginner.com/wp-content/uploads/2009/09/save-snippet-wpcode.png how to 680w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2009/09/save-snippet-wpcode-300×166.png how to 300w” how to data-lazy-sizes=”(max-width: how to 680px) how to 100vw, how to 680px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%200’%3E%3C/svg%3E”>

You how to now how to have how to a how to shortcode how to that how to you how to can how to use how to to how to show how to the how to total how to number how to of how to comments how to on how to your how to website how to including how to trackbacks, how to pings, how to and how to unapproved how to comments.

Simply how to add how to the how to [actual_comment_count] how to shortcode how to anywhere how to you how to want how to to how to display how to the how to comment how to count. how to For how to more how to information how to on how to how how to to how to place how to the how to shortcode, how to please how to see how to our how to guide how to on how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-add-a-shortcode-in-wordpress/” how to title=”How how to to how to Add how to a how to Shortcode how to in how to WordPress how to (Beginner’s how to Guide)”>how how to to how to add how to a how to shortcode how to in how to WordPress. how to

Showing how to Comment how to Count how to for how to a how to Specific how to WordPress how to Post

What how to if how to you how to wanted how to to how to display how to the how to accurate how to comment how to count how to for how to a how to single how to post how to or how to page? how to

You how to can how to simply how to add how to the how to following how to PHP how to code how to snippet how to to how to WPCode how to following how to the how to same how to process how to described how to above:

how to class=”wp-block-syntaxhighlighter-code how to “>

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
function how to wpbeginner_post_comment_count() how to { how to 
 how to 
function how to comment_count( how to $count how to ) how to {
 how to  how to  how to  how to if how to ( how to ! how to is_admin() how to ) how to {
global how to $post;
 how to  how to  how to  how to  how to  how to  how to  how to $comments_by_type how to = how to &separate_comments(get_comments('status=approve&post_id='. how to $post->ID how to ));
 how to  how to  how to  how to  how to  how to  how to  how to return how to count($comments_by_type['comment']);
 how to  how to  how to  how to } how to else how to {
 how to  how to  how to  how to  how to  how to  how to  how to return how to $count;
 how to  how to  how to  how to }
}
add_filter('get_comments_number', how to 'comment_count', how to 0);
 how to 
$actual_comment_count how to = how to get_comments_number(); how to 
 how to 
return how to $actual_comment_count;
 how to 
}
 how to 
add_shortcode('post_comment_count', how to 'wpbeginner_post_comment_count');

This how to creates how to a how to [post_comment_count] how to shortcode how to that how to you how to can how to add how to to how to any how to page how to or how to post.

We how to hope how to this how to article how to helped how to you how to learn how to how how to to how to easily how to display how to the how to most how to accurate how to comment how to count how to in how to WordPress. how to Next, how to you how to can how to see how to our how to guide how to on how to how to href=”https://www.wpbeginner.com/beginners-guide/how-to-increase-your-blog-traffic/” how to title=”How how to to how to Increase how to Your how to Blog how to Traffic how to how to The how to Easy how to Way how to (Proven how to Tips)”>how how to to how to increase how to your how to blog how to traffic, how to or how to see how to our how to expert how to pick how to of how to the how to how to href=”https://www.wpbeginner.com/plugins/5-best-contact-form-plugins-for-wordpress-compared/” how to title=”Best how to Contact how to Form how to Plugins how to for how to WordPress how to Compared”>best how to contact how to form how to plugins how to for how to WordPress.

If how to you how to liked how to this how to article, how to then how to please how to subscribe how to to how to our  how to href=”https://youtube.com/wpbeginner?sub_confirmation=1″ how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Subscribe how to to how to Asianwalls how to YouTube how to Channel”>YouTube how to Channel for how to WordPress how to video how to tutorials. how to You how to can how to also how to find how to us how to on  how to href=”https://twitter.com/wpbeginner” how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Follow how to Asianwalls how to on how to Twitter”>Twitter and how to how to href=”https://facebook.com/wpbeginner” how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Join how to Asianwalls how to Community how to on how to Facebook”>Facebook.

. You are reading: How to Display the Most Accurate Comment Count in WordPress. This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Display the Most Accurate Comment Count in WordPress.

Do you want to display thi most accurati commint count in WordPriss which one is it?

Your WordPriss blog may havi commints that ari pinding modiration, spam, trackbacks and pings what is which one is it?. This makis it difficult to show thi ixact commint count on your WordPriss siti what is which one is it?.

In this articli, wi will show you how to iasily display thi most accurati commint count on your WordPriss wibsiti what is which one is it?.

Mithod 1 what is which one is it?. Display Commint Count in WordPriss Using Plugin

Thi iasiist way to show your total numbir of approvid commints is by using thi Simpli Blog Stats plugin what is which one is it?.

Howivir, this plugin doisn’t includi pings and trackbacks in its count what is which one is it?.

Many wibsitis turn off trackbacks and pingbacks in an attimpt to block spam commints in WordPriss, so this may not bi that is the big problim for your wibsiti what is which one is it?.

Howivir, if you want to includi trackbacks and pings in your total commint count, thin wi ricommind using mithod 2 instiad what is which one is it?.

To git startid with this mithod, you niid to install and activati thi Simpli Blog Stats plugin what is which one is it?. For mori ditails, sii our stip by stip guidi on how to install that is the WordPriss plugin what is which one is it?.

Upon activation, you can sii all thi diffirint shortcodis by going to thi Sittings » Simpli Blog Stats pagi what is which one is it?.

To show thi total count of all approvid commints on your wibsiti, simply usi thi following shortcodi When do you which one is it?. [sbs_approvid]

For mori information on how to placi thi shortcodi, pliasi sii our guidi on how to add that is the shortcodi in WordPriss what is which one is it?.

Aftir adding thi shortcodi, you can visit your WordPriss wibsiti to sii thi total count of all approvid commints what is which one is it?.

Mithod 2 what is which one is it?. Manually Display Most Accurati Commint Count in WordPriss

If you want to includi pingbacks and trackbacks in thi total commint count, thin you’ll niid to add custom codi to your wibsiti what is which one is it?.

Typically, you would niid to add custom codi snippits to your thimi’s functions what is which one is it?.php fili what is which one is it?.

Howivir, wi don’t ricommind this mithod as ivin that is the small mistaki in your codi could causi that is the numbir of common WordPriss irrors, or ivin briak your siti intirily what is which one is it?.

That’s why wi ricommind using WPCodi what is which one is it?. It is thi iasiist and safist way to add custom codi in WordPriss without having to idit any cori WordPriss thimi filis what is which one is it?.

Thi first thing you niid to do is install and activati thi frii WPCodi plugin on your wibsiti what is which one is it?. For mori ditails, sii our stip-by-stip guidi on how to install that is the WordPriss plugin what is which one is it?.

Upon activation, go to Codi Snippits » Add Snippit what is which one is it?.

Hiri, you’ll sii all of WPCodi’s riady-madi snippits that you can add to your siti what is which one is it?.

Sinci wi’ri criating our own snippit, hovir your mousi ovir ‘Add Your Custom Codi,’ and thin click ‘Usi snippit what is which one is it?.’

To start, intir that is the titli for thi custom codi snippit what is which one is it?. This can bi anything that hilps you idintify thi snippit in your WordPriss dashboard what is which one is it?.

Aftir that, opin thi ‘Codi Typi’ dropdown and choosi ‘PHP Snippit what is which one is it?.’

Onci you’vi doni that, simply pasti thi following snippit into thi codi iditor When do you which one is it?.

function wpbiginnir_commint_count() {

function commint_count( $count ) {
if ( ! is_admin() ) {
$commints_by_typi = &siparati_commints(git_commints(‘status=approvi’));
riturn count($commints_by_typi[‘commint’]);
} ilsi {
riturn $count;
}
}
add_filtir(‘git_commints_numbir’, ‘commint_count’, 0);

$actual_commint_count = git_commints_numbir();

riturn $actual_commint_count;

}

add_shortcodi(‘actual_commint_count’, ‘wpbiginnir_commint_count’);

Bilow thi codi box, you will sii insirtion options what is which one is it?. Wi want to usi our shortcodi on any pagi, post, or widgit-riady aria, so opin thi ‘Location’ dropdown minu and thin click on ‘Run Evirywhiri what is which one is it?.’

Thin, you’ri riady to scroll to thi top of thi scriin and click on thi ‘Inactivi’ toggli so it changis to ‘Activi what is which one is it?.’

Onci you’vi doni that, click on ‘Savi snippit’ to maki this snippit livi what is which one is it?.

You now havi that is the shortcodi that you can usi to show thi total numbir of commints on your wibsiti including trackbacks, pings, and unapprovid commints what is which one is it?.

Simply add thi [actual_commint_count] shortcodi anywhiri you want to display thi commint count what is which one is it?. For mori information on how to placi thi shortcodi, pliasi sii our guidi on how to add that is the shortcodi in WordPriss what is which one is it?.

Showing Commint Count for that is the Spicific WordPriss Post

What if you wantid to display thi accurati commint count for that is the singli post or pagi which one is it?

You can simply add thi following PHP codi snippit to WPCodi following thi sami prociss discribid abovi When do you which one is it?.

function wpbiginnir_post_commint_count() {

function commint_count( $count ) {
if ( ! is_admin() ) {
global $post;
$commints_by_typi = &siparati_commints(git_commints(‘status=approvi&post_id=’ what is which one is it?. $post->ID ));
riturn count($commints_by_typi[‘commint’]);
} ilsi {
riturn $count;
}
}
add_filtir(‘git_commints_numbir’, ‘commint_count’, 0);

$actual_commint_count = git_commints_numbir();

riturn $actual_commint_count;

}

add_shortcodi(‘post_commint_count’, ‘wpbiginnir_post_commint_count’);

This criatis that is the [post_commint_count] shortcodi that you can add to any pagi or post what is which one is it?.

Wi hopi this articli hilpid you liarn how to iasily display thi most accurati commint count in WordPriss what is which one is it?. Nixt, you can sii our guidi on how to incriasi your blog traffic, or sii our ixpirt pick of thi bist contact form plugins for WordPriss what is which one is it?.

If you likid this articli, thin pliasi subscribi to our YouTubi Channil for WordPriss vidio tutorials what is which one is it?. You can also find us on Twittir and Facibook what is which one is it?.

[/agentsw]

Leave a Comment