Table of Contents
Why do I need to display the total number of comments in WordPress?
Method 1: Use plugin to display WordPress comment count (simple)
Method 2: Use code to display the number of comments (most accurate)
Home CMS Tutorial WordPress How to display the total number of comments in WordPress

How to display the total number of comments in WordPress

Apr 20, 2025 am 07:12 AM
wordpress Why 2025

Do you want to show the total number of comments on your WordPress site?

Comments are the primary way for users to interact with your content. By showing the total number of comments, you can encourage more people to join the conversation.

In this article, we will show you how to easily display the total number of comments on your WordPress website.

How to display the total number of comments in WordPress

Why do I need to display the total number of comments in WordPress?

An active comment section can improve the visitor experience, create a sense of community, and keep people on your website longer. Some people may even go back to a page or post just to read the latest comments.

You will want to do everything you can to get more comments on your WordPress posts. First, we recommend allowing users to subscribe to comments and ask questions at the end of each post to encourage debate.

You can also display the total number of comments. Higher numbers 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.

That being said, let's see how to display the total number of comments in WordPress. Just use the quick link below to jump directly to the method you want to use.

  • Method 1: Use plugin to display WordPress comment count (simple)
  • Method 2: Use code to display the number of comments (most accurate)

Method 1: Use plugin to display WordPress comment count (simple)

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 trackbacks and pingbacks in an attempt to block spam in WordPress, so this may not be a big problem for your website.

However, if you want to include references and pings in the total number of comments, then we recommend using Method 2.

To get started with this method, you need to install and activate the Simple Blog Statistics plugin. If you need help, see our 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 total number of comments in WordPress

Here, just click to expand the Shortcode section.

Now you will see all the shortcodes that can be used to display different statistics such as total number of comments, number of registered users, number of posts, category, etc.

How to display the total number of comments in WordPress

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] .

When you have the shortcode you want to use, just go to the page or post where you want to display the total number of comments.

Here, click the ' ' button to add a new block. You can now start typing in the "short code" and select the correct block when it appears.

How to display the total number of comments in WordPress

Next, just paste the short code into the block.

You can add any text you want to display before or after the shortcode.

How to display the total number of comments in WordPress

Another option is to use short codes within paragraph blocks.

Just add a shortcode where you want to display the total number of comments.

How to display the total number of comments in WordPress

Using paragraph blocks also allows you to style the total number of comments using standard text formatting settings. For example, you can set it to bold or italics, or change the text color.

When finished, click the Publish or Update button to save the changes. You can now visit your website to view the number of comments in real time.

How to display the total number of comments in WordPress

Show total number of comments in sidebar widget

You can also add the total number of comments to the sidebar or similar using the same shortcode. This is an easy way to display the comment count for the entire WordPress website, as shown in the following figure.

How to display the total number of comments in WordPress

To add a comment count to the sidebar or similar, go to Appearance » Widgets .

Here you will see a list of all available widget areas. For example, in the image below, we are using the ThemeIsle Hestia Pro theme, which has multiple widget-ready areas including sidebars, headers, and footers.

How to display the total number of comments in WordPress

The widget-ready area is defined by your WordPress theme, so you may see different content depending on the theme you are using.

Now click the blue " " button and enter "Paragraph". When the paragraph widget is displayed, drag it to the area where you want to display the comment count.

How to display the total number of comments in WordPress

You can then paste the [sbs_approved] shortcode into the widget and enter any text you want to display before or after the total number of comments.

When finished, click Update to store your changes.

How to display the total number of comments in WordPress

Now if you visit your website, you will see the total comment count widget running.

Note: If you use a block-based theme, you can edit the widget-ready area of ​​the site by going to Theme » Editor .

Method 2: Use code to display the number of comments (most accurate)

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 even a small error in the code can cause many common WordPress errors and even completely destroy your website.

This is why we recommend using WPCode. It allows you to add custom code in WordPress without editing 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 WordPress plug-ins.

Once activated, go to Code Snippet » Add snippet .

How to display the total number of comments in WordPress

Here you will see all the ready-made snippets that can be added to the website using WPCode. This includes code that allows you to disable attachment pages, upload SVG files, disable automatic updates, and more.

To create your own snippet, hover over Add your custom code and click the Use snippet button below.

How to display the total number of comments in WordPress

First, enter the title of the custom code snippet. This is for your reference only, so it can be anything that can help you identify code snippets.

When you have done this, open the Code Type drop-down list and select the PHP Fragment option. Then, paste the following code snippet into the Code Preview editor:

How to display the total number of comments in WordPress

Below the code box, you will also see some insert options. Select the Automatic Insert option to automatically insert code snippets and execute them on your website.

How to display the total number of comments in WordPress

After that, scroll to the top of the screen and click the Inactive switch to make it appear Active.

When finished, click Save Fragment to make the comment clip take effect.

How to display the total number of comments in WordPress

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

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

We hope this tutorial helps you learn how to display the total number of comments in WordPress. You may also want to learn how to create the best social media plugins for email newsletters and WordPress.

The above is the detailed content of How to display the total number of comments in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

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 Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

WorldCoin (WLD) price forecast 2025-2031: Will WLD reach USD 4 by 2031? WorldCoin (WLD) price forecast 2025-2031: Will WLD reach USD 4 by 2031? Apr 21, 2025 pm 02:42 PM

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 drops sharply to $65 Litecoin (LTC) price drops sharply to $65 Apr 21, 2025 pm 06:15 PM

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

What does cross-chain transaction mean? What are the cross-chain transactions? What does cross-chain transaction mean? What are the cross-chain transactions? Apr 21, 2025 pm 11:39 PM

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 market trend chart in the past decade (analysis of Bitcoin price historical trends from 2014 to 2025) Bitcoin market trend chart in the past decade (analysis of Bitcoin price historical trends from 2014 to 2025) Apr 21, 2025 pm 07:30 PM

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

Rexas Finance (RXS) can surpass Solana (Sol), Cardano (ADA), XRP and Dogecoin (Doge) in 2025 Rexas Finance (RXS) can surpass Solana (Sol), Cardano (ADA), XRP and Dogecoin (Doge) in 2025 Apr 21, 2025 pm 02:30 PM

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

Galaxy Digital gets SEC approval for Nasdaq listing and reorganization Galaxy Digital gets SEC approval for Nasdaq listing and reorganization Apr 21, 2025 pm 02:45 PM

Galaxy Digital Holdings has been approved by the U.S. Securities and Exchange Commission (SEC) to officially launch the restructuring plan! Galaxy Digital has been approved by the SEC, and its Nasdaq listing and corporate structure restructuring plan has officially entered the next stage. The news was announced on Monday. The SEC has approved the registration statement for Galaxy Digital. The move is a key step in the company's plan to move its corporate structure from the Cayman Islands to Delaware, and at the same time, it will set up a new parent company, NewPubCo. "We are excited that the registration statement will take effect, which marks an important milestone in the development of Galaxy Digital and will continue to follow," said the CEO of Galaxy Digital.

Recently, cryptocurrency markets have been facing turmoil, and Cardano (ADA) has dropped below key support levels amid economic uncertainty. Recently, cryptocurrency markets have been facing turmoil, and Cardano (ADA) has dropped below key support levels amid economic uncertainty. Apr 21, 2025 pm 02:33 PM

Cryptocurrency market turmoil has intensified, and Cardano (ADA) has fallen below key support levels, raising concerns among investors. This article will analyze the recent performance of ADA and compare the strong growth momentum of another cryptocurrency, Coldware (COLD). ADA prices have continued to decline in the past five months, falling below the $0.61 support level on April 7, 2025, triggering volatility in the overall cryptocurrency market. At the same time, Coldware (COLD)'s pre-sale performed well, with financing of US$2.4 million in the second phase. So, what are the advantages of Coldware compared to Cardano? Coldware rises against the trend. In the same market environment where ADA prices fall, Coldware(C

Ranking of exchanges in low-cost fees in 2025 Ranking of exchanges in low-cost fees in 2025 Apr 22, 2025 am 06:21 AM

The exchange with the lowest handling fee in the currency circle is Binance, with a spot trading rate of 0.1%. 1. Binance: The spot transaction fee rate is 0.1%, and BNB deduction fee is supported. 2. OKX: The spot transaction fee rate is 0.02%-0.15%, suitable for high-frequency trading. 3. Gate.io: The spot transaction fee rate is 0.2%, and the coin is listed quickly.

See all articles