DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

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.


  1. 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

  2. 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?


  3. 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 ?!

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

  5. I know this but what if I want to display total number of registered members today….remember i want to show count by today’s date…

    help me

Leave a Comment

Your email address will not be published. Required fields are marked *