WordPress stores all registered users in its database. You can display the total number of registered users on your site using a simple PHP function. On ruachost.com, this is often used to highlight site popularity or community size.
Why Show Registered Users?
-
Demonstrates site growth and credibility.
-
Encourages new visitors to register.
-
Useful for membership sites, forums, or communities.
Steps to Display Registered Users
-
Log in to WordPress with an administrator account.
-
In the dashboard, go to Appearance → Theme Editor.
-
From the right‑hand column, select the file named functions.php.
-
Scroll to the bottom of the file and add the following code:
// Function to return user count function wpb_user_count() { $usercount = count_users(); $result = $usercount['total_users']; return $result; } // Creating a shortcode to display user count add_shortcode('user_count', 'wpb_user_count'); -
Click Update File to save changes.
⚙️ Using the Shortcode
-
To display the total number of registered users anywhere on your site, type:
[user_count]
✅ WordPress will automatically replace [user_count] with the total number of registered users.
Important Notes
-
Always back up your site before editing theme files.
-
Consider using a child theme to preserve changes during updates.
-
This shortcode works in posts, pages, and widgets.