How 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.
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.
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]
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.
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 .
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.
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.
Once done, just paste the following code snippet into the code editor:
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.
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

WorldCoin (WLD) stands out in the cryptocurrency market with its unique biometric verification and privacy protection mechanisms, attracting the attention of many investors. WLD has performed outstandingly among altcoins with its innovative technologies, especially in combination with OpenAI artificial intelligence technology. But how will the digital assets behave in the next few years? Let's predict the future price of WLD together. The 2025 WLD price forecast is expected to achieve significant growth in WLD in 2025. Market analysis shows that the average WLD price may reach $1.31, with a maximum of $1.36. However, in a bear market, the price may fall to around $0.55. This growth expectation is mainly due to WorldCoin2.

Litecoin (LTC) price plummeted to $65 in early April, down nearly 7.5% in a week, echoing the plunge in the wider cryptocurrency market. The market crash caused billions of dollars to evaporate market value, Bitcoin (BTC) fell below $75,000, and altcoins generally fell. Macro factors such as rising U.S. Treasury yields and expected interest rates appear to intensify risk aversion in global markets. In addition, the large outflow of funds from Bitcoin spot ETFs further hits the confidence of retail investors and institutional investors. Against this backdrop, Litecoin is once again facing its long-term resistance level - the 200-week exponential moving average (EMA). The EMA had suppressed LTC prices in July 2023, when the price was close to $88. Historically, LTC and the

Factors of rising virtual currency prices include: 1. Increased market demand, 2. Decreased supply, 3. Stimulated positive news, 4. Optimistic market sentiment, 5. Macroeconomic environment; Decline factors include: 1. Decreased market demand, 2. Increased supply, 3. Strike of negative news, 4. Pessimistic market sentiment, 5. Macroeconomic environment.

Exchanges that support cross-chain transactions: 1. Binance, 2. Uniswap, 3. SushiSwap, 4. Curve Finance, 5. Thorchain, 6. 1inch Exchange, 7. DLN Trade, these platforms support multi-chain asset transactions through various technologies.

Bitcoin price has experienced multiple cycles of fluctuations and growth. 1. From 2013 to 2014, the price soared from less than $10 to $1,150, and then plummeted to $200. 2. From 2015 to 2016, prices stabilized and rebounded, and infrastructure improvements enhanced market confidence. 3. From 2017 to 2018, the price plummeted to US$3,000 after exceeding US$20,000, and the tightening of China's regulatory policies caused an impact. 4. From 2019 to 2021, the price rebounded to more than US$10,000, and exceeded US$60,000 in 2021, and institutional investors entered the market to drive the rise. 5. From 2022 to 2024, the price rebounded to $50,000 after the market correction, and the launch of US ETFs brought new funds. 6. At the beginning of 2025, the price is around 1

In the bustling world of cryptocurrencies, new opportunities always emerge. At present, KernelDAO (KERNEL) airdrop activity is attracting much attention and attracting the attention of many investors. So, what is the origin of this project? What benefits can BNB Holder get from it? Don't worry, the following will reveal it one by one for you.

This article lists the ranking of APPs for legal platforms for virtual currency transactions, emphasizing that compliance is an important consideration for choosing a platform. The article recommends platforms such as Coinbase, Gemini, and Kraken, and reminds investors to study regulatory information and pay attention to security records when making choices. At the same time, the article emphasizes that virtual currency transactions are high-risk and investments should be cautious.

In the volatile cryptocurrency market, investors are looking for alternatives that go beyond popular currencies. Although well-known cryptocurrencies such as Solana (SOL), Cardano (ADA), XRP and Dogecoin (DOGE) also face challenges such as market sentiment, regulatory uncertainty and scalability. However, a new emerging project, RexasFinance (RXS), is emerging. It does not rely on celebrity effects or hype, but focuses on combining real-world assets (RWA) with blockchain technology to provide investors with an innovative way to invest. This strategy makes it hoped to be one of the most successful projects of 2025. RexasFi
