Resources     Blog  

  1. Home
  2. WordPress Tutorials
  3. How to Display the Total Number of Posts on Your WordPress Website

How to Display the Total Number of Posts on Your WordPress Website

Do you want to display the total number of posts on your WordPress website? If you have a website that has been up and running for a long time, showing the large number of posts you’ve created over the years should be a badge of honor. On the other hand, if you have a new website, this will show just how much your website is growing.

For visitors, the number of posts will show your consistency. For example, if you create a new post every week, the number will grow once per week. This makes it easy to showcase how much content you produce and how consistent you are all in one number. Today, I will demonstrate how to display post count in WordPress using two methods.

How Important is Adding This Feature

Not very, but when you think about it, how important are other features? There are many features that a website can live without and this will definitely not make or break a website, but as with most features, it’s there if you want it. If you think that this will look good in a blank spot on your website’s homepage or want it as a personal reminder of the total number of posts in WordPress, then it will serve that purpose.

How to Display the Total Number Posts on Your WordPress Website

Today, I will demonstrate how to display post count in WordPress using two methods. The first method is to use the Simple Blog Stats plugin. It’s a great plugin that shows you all kinds of stats about your website like the total number of posts, pages, drafts, comments and so much more. Even if you do not plan on sharing this information with visitors, it is still a great tool to use. The second option is to edit the functions.php file of your theme to display the post count.

Let’s start by clicking on Plugins and selecting the Add New option on the left-hand admin panel.

Add New

Search for Simple Blog Stats in the available search box. This will pull up additional plugins that you may find helpful.

Search for Simple Blog Stats in the available search box.

Scroll down until you find the Simple Blog Stats plugin and click the “Install Now” button and activate the plugin for use.

click the "Install Now" button

On the left-hand admin panel click on Settings and select the Simple Blog Stats option. This will pull up the main settings page.

click on Settings and select the Simple Blog Stats option.

Every number you want is obtained by using shortcodes. Click on the Shortcodes section to display a full list of shortcodes.

Click on the Shortcodes section

You will be able to place these shortcodes anywhere on your website to display them. For example, you could place it in a sentence like, “Our blog has X posts since our inception” where X would be replaced with the shortcode. You will see an Output Column, which is what using the shortcode will display. If you want it for your personal records, simply read the Output Column to know the results.

To perform the next method you will need access to your cPanel, which is provided to you by your web host when you create an account with them. You need to access your theme’s functions.php file and edit the code.

Let’s start by logging into the cPanel and clicking on the File Manager option. The File Manager will allow you to access all of the files related to your website.

Click on the File Manager option.

You need to locate your theme’s functions.php file. Click on the public_html directory. Click on the wp-content folder. Click on the themes folder. Click on the folder of the theme you are currently using. Right-click on the functions.php file and select the Edit option.

Select the "Edit" option.

A pop-up window will show up. This box will warn you to create a backup of your files before editing anything. This will ensure that you can revert your website back to the earlier version if something goes wrong. Click on the “Edit” button. A new tab will open containing all of the code from the file.

You have two options to choose from when deciding how to add the code. You can create a template tag or create a shortcode. I will provide the code for both, but you only need one.

The following code is for the template tag method. The tag is called post_count and will display the number of posts when called:

function post_count() {
$total = wp_count_posts()->publish;
echo ‘Total Posts: ‘ . $total;

If you do not want to use a template tag and would rather use a shortcode, then add these lines of code instead:

function post_count() {
$total = wp_count_posts()->publish;
return $total;

You can now use the shortcode [total_posts] to add anywhere on your website. Once you have inserted the code you chose into the functions.php file, click on the “Save Changes” button to finish.

Click on the "Save Changes" button.

Congratulations, you have successfully added the WordPress published posts count to your website. The plugin is very convenient to use and has a lot of additional features, but if you only want the WordPress post count, then adding it by using code is better.

Don’t Be Afraid to Share Your Stats

When you are just starting out your stats are never that impressive, but don’t hide them. Instead, you should use them to showcase how much your website has grown since it has been created. Of course, some things don’t always go as planned and growth may eventually start to decline.

Decline happens, but don’t get discouraged, even the larger websites see a noticeable decline. Of course, if this happens, trying to hide the fact looks worse than the actual decline. If you choose to make your stats public, make sure you are ready to handle the good times and the bad times.

Which method have you chosen to use? If you have chosen to use the second method, did you pick the template tag or shortcode option?

Author: Chris Racicot

Chris is the Support Manager at GreenGeeks and has been with the company since 2010. He has a passion for gaming, scripting and WordPress. When he’s not enjoying his sleep, he’s working on his guitar skills and fiddling with 3d printing.

Was this article helpful?

Related Articles

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.