2 easy way to show total number of Posts in wordpress website

Have you ever wanted to show the total number of Posts in wordpress websiteYou’ll learn here about showing the total number of posts but excluding the specific category. Displaying the total number of articles may help illustrate the flexibility of your blog and inspires users to view for more content.

In this article, we will display two easy ways to show the total number of posts on the WordPress site.

Method 1: Display Total Number of Posts in WordPress via Plugin

This is the easiest method and it is recommended for all the users.

  • First, install and activate the Simple Blog Stats plugin. For more information, see our step by step instructions on how to Install a plugin in WordPress?
  • After the activation visits Settings » Simple Blog Stats to configure plugin settings.
  • The Blog Stats plugin shows you useful WordPress stats like the total number of comments, pages, posts and much more. You can simply show these stats using shortcodes everywhere on your WordPress site.

sbsshortcodes

  • For this copy [sbs_posts] shortcode and add it to any of the WordPress posts, page or shortcode enabled sidebar widget. It will display the total number of published posts on your WordPress site.

numberofposts

  • You can also use [sbs_blog_stats] which will display all blog stats including the total number of posts.

Read Also: Top 8 WordPress Plugin for SEO

Method 2. Manually show Total Number of Posts in WordPress

In this method, you have to add code in your WordPress site. It will help you to add the number of posts in the WordPress homepage.

  • First of all add this code to your theme’s functions.php file or a site-specific plugin.
function wpb_total_posts() {

$total = wp_count_posts()->publish;

echo ‘Total Posts: ‘ . $total;

}

  • It output the number of posts when the template tag “wpb_total_posts” is called
  • In your theme files add <?php wpb_total_posts(); ?> where you want to show total number of posts.
  • In case you don’t want to use the template tag, then you can create and use a shortcode that do absolutely the same thing.
  • After that copy and paste the below code to your theme’s functions.php file or a site-specific plugin to create a shortcode:
function wpb_total_posts() {

$total = wp_count_posts()->publish;

return $total;

}

add_shortcode(‘total_posts’,’wpb_total_posts’);

  • You can now use the shortcode [total_posts] for displaying total number of posts in any posts or sidebar widgets.


WRAPPING UP

We hope that this article completely helped you in displaying the number of posts on the WordPress site. As the above two methods are quite easy to fix your issues.

Get more information related to this by contacting us at wordpress customer service, dial + 1 844 275 0975(Toll-Free). We will help you instantly to resolve all your issues.



Leave a Reply