Do you want to display the total number of WordPress users on your entire site? Use the following code to get the total number of users, and then display it in your theme. This returns ALL users, regardless of User Level.
<?php // Get total number of users $total_users = count_users(); echo $total_users['total_users'] . ' users.'; ?>
The $total_users
variable will just return the number. You can change the word “users” to say whatever you want (registered users, people, etc.).
I’d love to see how you use this. Please share in the comments.
Reference count_users() in the WordPress Codex.
We Recommend
https://kinsta.com › wordpress-hosting
Fast and secure infrastructure, worldwide CDN, edge caching, 35 data centers, and enterprise-level features included in all plans. Free site migrations.
https://gravityforms.com › features
Create custom web forms to capture leads, collect payments, automate your workflows, and build your business online. All without ever leaving WordPress.
Leave a Comment