Display the number of online users in WordPress

If you have ever used or just visited a forum, you have probably noticed a counter which shows how many users are online at the given moment. Depending on the forum or the website, this counter can look different. Usually, it shows how many users are online and how many of those are registered users, i.e. how many are just guests.

While WordPress by default doesn’t have the feature installed, you can still track the number of online users by using a simple plugin.

WP UserOnline


Online Users

WP UserOnline is a free plugin which can show you exactly what you need. Not only you can display the number of online people, but this plugin will tell you where they are on your website and will divide them into categories – Members, Guests, and Searchbots.

Install the plugin and set it up:

  1. Go to Plugins->Add New
  2. Search for “WP-UserOnline”, install and activate the plugin
  3. Navigate to Settings->UserOnline

This is where you can set up your plugin. You can set the time in seconds after which the online user will be removed from the database and thus removed from the list of online users. Choose a different URL for the UserOnline page where the information is displayed and choose if you want to link usernames with the author pages.

After that, you can change the text which represents users, members, guests, and bots. This is useful if you run a site in a different language or simply want to use other nomenclature in the English language.

  1. Save changes
  2. Go to Pages->Add New
  3. Choose a name
  4. You can choose page name that you want, but the important part is to match the URL to one in the plugin settings from step #3. If you didn’t change settings in the plugin, your new page must have URL like this one:


  5. Make sure to open Text Editor and paste the following shortcode:
  6. Save changes

This is how your page might look like:
Online Users

Set up the widget:

That’s it. If you open the page you have just created, you should see there is at least one active user on the site – that’s you.

If it’s not only you who needs to see the number of online users, you should make the page visible to everyone. A simple way of doing this is already integrated into the plugin – it’s a widget.

  1. Navigate to Appearance->Widgets
  2. Find User Online widget
  3. Drag and drop it in the widget area where you want the counter to appear
  4. Choose a title
  5. Choose a counter type

Show statistics:

There are few different statistics you can show:

  • Users online count
  • Users browsing the current page
  • Users browsing your site
  • Users online count + users browsing the current page
  • Users online count + users browsing your site
  • Save changes

If you want to place the counter somewhere else in your theme, you will need the following code:

<?php if (function_exists('users_online')): ?>
<p>Users online: <div id="useronline-count"><?php users_online(); ?></div></p>
<?php endif; ?>

Enjoy your new feature, but if you want an even easier solution, check out 5sec Who’s Online plugin.

Start Blog Book


This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

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