Displaying the user count in WordPress
Learn how to display the user count on WordPress pages by adding a brief code snippet to the functions.php file of your theme.
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:
-
Log in to WordPress as the administrator.
-
On the Dashboard in the left sidebar, click Appearance, and then click Theme Editor:
-
In the right sidebar, under Theme Files, click Theme Functions (functions.php).
-
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');
-
Click Update File. WordPress saves the changes to the functions.php file.
-
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:
Save your changes, and then view the post:
Related Articles
Updated 1 day ago