search
HomeCMS TutorialWordPressHow to display the most accurate comment count in WordPress

Do you want to display the most accurate number of comments in WordPress?

Your WordPress site may have comments, spam, quote announcements, and pings that are pending review. This makes it difficult to display the exact number of comments on your website.

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

How to display the most accurate comment count in WordPress

Why display accurate comment counts in WordPress?

Comments allow readers to interact with you and other visitors. This helps create a sense of community and bring people back to your website. That being said, you will want to do everything you can to get more comments on your WordPress posts.

You can allow users to subscribe to comments, ask questions in each post to try to spark discussions, and more. Another option is to display accurate comment counts.

High comment counts will make visitors want to join the conversation. It's also a social proof, as readers may visit your post just to understand why so many people have commented.

There is no default way to display accurate comment counts in WordPress, especially when your website receives a lot of citations and pings. Spam can also make it difficult to display accurate comment counts.

That being said, let's see how to use the free plugin to display accurate comment counts on WordPress websites. Just use the quick link below to jump directly to the method you want to use:

  • Method 1: Use simple blog statistics (fast and easy)
  • Method 2: Use custom shortcodes (including ping, citations, and unapproved comments)

Method 1: Use simple blog statistics (fast and easy)

The easiest way to display accurate comment counts is to use simple blog statistics. This plugin displays the total number of approved comments and reviewed comments. However, ping and reference are not included in its count.

Many websites turn off Trackback and pingback to block spam in WordPress, so this may not be a big problem for your website. However, if you want to include reference references and pings in your comment count, then we recommend using Method 2.

First, you need to install and activate the Simple Blog Statistics plugin. For more details, see our step-by-step guide on how to install WordPress plug-ins.

Once activated, you can view all the short codes for the plugin by going to the Settings » Simple Blog Statistics page.

How to display the most accurate comment count in WordPress

Here, just click to expand the Shortcode section.

To display the total number of approved comments on your WordPress blog, simply use the following shortcode: [sbs_approved]

How to display the most accurate comment count in WordPress

If you want to display the total number of approved comments and comments that are still in the WordPress comment review queue, you can use [sbs_comments].

For more information on how to place shortcodes, see our guide on how to add shortcodes in WordPress.

How to display the most accurate comment count in WordPress

After adding the shortcode, you can visit the WordPress website to view the total number of comments in real time.

Method 2: Use custom shortcodes (including ping, citations, and unapproved comments)

If you want to include pingback and trackback in the total number of comments, you need to add custom code to your website.

Typically, the tutorial will ask you to add custom code snippets to the theme's functions.php file. However, we do not recommend using this method, as a small error in the code can cause many common WordPress errors. Or worse yet, completely destroy your website.

This is why we recommend using WPCode. This is the easiest and safest way to add custom code in WordPress without editing any 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 WordPress plug-ins.

Once activated, you need to go to Code Snippet » Add snippet .

How to display the most accurate comment count in WordPress

Here you will see all the ready-made snippets of WPCode that you can add to your website.

We will create a custom shortcode that allows you to add accurate comment counts to any page, post, or widget ready area. First, hover over Add Custom Code and click Use Code Snippets.

How to display the most accurate comment count in WordPress

First, you need to enter the title of the custom code snippet. This can be anything that can help you identify snippets of code in your WordPress dashboard.

After that, just open the Code Type drop-down list and select PHP Fragment.

How to display the most accurate comment count in WordPress

Once done, just paste the following code snippet into the code editor:

How to display the most accurate comment count in WordPress

After that, scroll to the top of the screen and click Inactive to change it to Active.

Once you're done, just click Save Code Snippet to make the code snippet appear on your website.

How to display the most accurate comment count in WordPress

You now have a shortcode that can be used to display the total number of comments, including quotes, pings, and unapproved comments.

[actual_comment_count] Just add a shortcode anywhere you want to display the number of comments. For more information on how to place shortcodes, see our guide on how to add shortcodes in WordPress.

Show comment counts for specific WordPress posts

Do you want to display the number of comments for a single post or page?

You can add the following PHP code snippet to WPCode by following the same procedure above:

 functionwpbeginner_post_comment_count() { functioncomment_count( $count) { if( ! is_admin() ) { global$post; $comments_by_type= &separate_comments(get_comments('status=approve&post_id='. $post->ID )); returncount($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');

Depend on

Use it with one click in WordPress

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

We hope this article helps you understand how to easily display the most accurate comment count in WordPress. You might also want to read our guide on how to increase your blog traffic, or check out our expert selection of the best contact form plugins for WordPress.

The above is the detailed content of How to display the most accurate comment count in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How does WordPress's plugin ecosystem enhance its CMS capabilities?How does WordPress's plugin ecosystem enhance its CMS capabilities?May 14, 2025 am 12:20 AM

WordPresspluginssignificantlyenhanceitsCMScapabilitiesbyofferingcustomizationandfunctionality.1)Over50,000pluginsallowuserstotailortheirsiteforSEO,e-commerce,andsecurity.2)Pluginscanextendcorefeatures,likeaddingcustomposttypes.3)However,theycancausec

Is WordPress suitable for e-commerce?Is WordPress suitable for e-commerce?May 13, 2025 am 12:05 AM

Yes, WordPress is very suitable for e-commerce. 1) With the WooCommerce plugin, WordPress can quickly become a fully functional online store. 2) Pay attention to performance optimization and security, and regular updates and use of caches and security plug-ins are the key. 3) WordPress provides a wealth of customization options to improve user experience and significantly optimize SEO.

How to add your WordPress site in Yandex Webmaster ToolsHow to add your WordPress site in Yandex Webmaster ToolsMay 12, 2025 pm 09:06 PM

Do you want to connect your website to Yandex Webmaster Tools? Webmaster tools such as Google Search Console, Bing and Yandex can help you optimize your website, monitor traffic, manage robots.txt, check for website errors, and more. In this article, we will share how to add your WordPress website to the Yandex Webmaster Tool to monitor your search engine traffic. What is Yandex? Yandex is a popular search engine based in Russia, similar to Google and Bing. You can excel in Yandex

How to fix HTTP image upload errors in WordPress (simple)How to fix HTTP image upload errors in WordPress (simple)May 12, 2025 pm 09:03 PM

Do you need to fix HTTP image upload errors in WordPress? This error can be particularly frustrating when you create content in WordPress. This usually happens when you upload images or other files to your CMS using the built-in WordPress media library. In this article, we will show you how to easily fix HTTP image upload errors in WordPress. What is the reason for HTTP errors during WordPress media uploading? When you try to upload files to Wo using WordPress media uploader

How to fix the issue where adding media buttons don't work in WordPressHow to fix the issue where adding media buttons don't work in WordPressMay 12, 2025 pm 09:00 PM

Recently, one of our readers reported that the Add Media button on their WordPress site suddenly stopped working. This classic editor problem does not show any errors or warnings, which makes the user unaware why their "Add Media" button does not work. In this article, we will show you how to easily fix the Add Media button in WordPress that doesn't work. What causes WordPress "Add Media" button to stop working? If you are still using the old classic WordPress editor, the Add Media button allows you to insert images, videos, and more into your blog post.

How to set, get and delete WordPress cookies (like a professional)How to set, get and delete WordPress cookies (like a professional)May 12, 2025 pm 08:57 PM

Do you want to know how to use cookies on your WordPress website? Cookies are useful tools for storing temporary information in users’ browsers. You can use this information to enhance the user experience through personalization and behavioral targeting. In this ultimate guide, we will show you how to set, get, and delete WordPresscookies like a professional. Note: This is an advanced tutorial. It requires you to be proficient in HTML, CSS, WordPress websites and PHP. What are cookies? Cookies are created and stored when users visit websites.

How to Fix WordPress 429 Too Many Request ErrorsHow to Fix WordPress 429 Too Many Request ErrorsMay 12, 2025 pm 08:54 PM

Do you see the "429 too many requests" error on your WordPress website? This error message means that the user is sending too many HTTP requests to the server of your website. This error can be very frustrating because it is difficult to find out what causes the error. In this article, we will show you how to easily fix the "WordPress429TooManyRequests" error. What causes too many requests for WordPress429? The most common cause of the "429TooManyRequests" error is that the user, bot, or script attempts to go to the website

How scalable is WordPress as a CMS for large websites?How scalable is WordPress as a CMS for large websites?May 12, 2025 am 12:08 AM

WordPresscanhandlelargewebsiteswithcarefulplanningandoptimization.1)Usecachingtoreduceserverload.2)Optimizeyourdatabaseregularly.3)ImplementaCDNtodistributecontent.4)Vetpluginsandthemestoavoidconflicts.5)ConsidermanagedWordPresshostingforenhancedperf

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool