How to display the user count in WordPress

This article describes how to display the user count on WordPress pages.

If you are running a WordPress site with a large user base, you may want to share the registered user count with all of the visitors to your site. By doing so, you can help encourage them to sign up as well. Many new customers or users equate a large following (or user base) to trust. Additionally, sharing the user count can help show that your site is constantly growing.

Adding the user count

To add user count functionality to WordPress, follow these steps:

  1. Log in to WordPress as the administrator.
  2. On the Dashboard in the left sidebar, click Appearance, and then click Theme Editor:

    WordPress - Dashboard - Appearance - Theme Editor

  3. In the right sidebar, under Theme Files, click Theme Functions (functions.php).
  4. Copy the following code snippet and then paste it at the bottom of the functions.php file:

    function display_user_count() {
        $usercount = count_users();
        $result = $usercount['total_users'];
        return $result;
    }
    add_shortcode('user_count', 'display_user_count');
  5. Click Update File. WordPress saves the changes to the functions.php file.
  6. User count functionality is now enabled, but you must update the post or posts where you want this information to appear. To do this, open a post or page on the site, and then type [user_count] where you want to display the user count. For example:

    WordPress - User count example

    Save your changes, and then view the post:

    WordPress - User count example

Get WordPress Hosting

Article Details

Other Articles in This Category

Show More

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.