
If your blog allow user registration, what about displaying the total number of registered users? This simple code will allow you to do it easily.

If your blog allow user registration, what about displaying the total number of registered users? This simple code will allow you to do it easily.
To achieve this recipe, simply paste the following code anywhere in your theme files:
$users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users");
echo $users." registered users.";
Once you saved the file and refreshed your blog, the total number of users will be displayed.
4 Responses
I want to know which of the theme files you place this code and where exactly in a file….say if I pulled out a header, where exactly I place this code. Your answer could help many newbies like me. Hope for a response,
Thanks once more
Hi Guys;
I pasted the code $users = $wpdb->get_var(“SELECT COUNT(ID) FROM $wpdb->users”);
echo $users.” registered users.”; into a txt/html widget field and did not get a result.
Any tips?
Mike.
This code is not good, il doesn’t work on any html page, widget or theme files !!
Please could you help us where you put that code and hom ?!
Thanks
Works perfect. paste in some php file of your template and it works.
Trackbacks: