Post Pic

Display the total number of users of your WordPress blog

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

Jun 20 2012 10:40

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

Oct 11 2012 17:26

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.

Jan 25 2013 12:13

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

Mar 27 2013 05:42

Works perfect. paste in some php file of your template and it works.

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required

WP Theme of the week

Sponsored Likebox