Many websites like forums and bloggers blog add a widget to display all online visitors. If you also want to add similar kind of thing in your WordPress blog, this article is for you. In this article, I will show you how you can add the real time online visitors count in your WordPress website.
WP-UserOnline is a nice WordPress plugin which lets you achieve this thing in WordPress. It offers easy way to add real time visitors section in your WordPress blog. It also offers detailed statistics at backend to let you know more about visitors.
Install WP-UserOnline plugin in your WordPress blog and then navigate to Settings > UserOnline page to configure the settings of this plugin. When you will open this page, you will see few default settings. You can just hit the save button to continue with default settings. These default settings will work for most of the websites. Change only if you want to change something and know what you are doing.
Next step is to create a page where you want to display online users’ stats. Create a new page from WordPress dashboard. Be sure to keep the same permalink of the page which was mentioned in the settings page as “User Online URL”. Add [page_useronline] shortcode in the content of the page and publish the page.
To display the stats in the sidebar or footer, this plugin also comes with widget. So, you can add widgets to display the user online stats by adding the widget. Find the widget in the widget section of WordPress dashboard.
Alternatively you can also use the below code in the theme to display the stats without using widget.
<?php if (function_exists('users_online')): ?>
<p>Users online: <div id="useronline-count"><?php users_online(); ?></div></p>
<?php endif; ?>
Try this plugin and share your views with us via comments.