How to display the count of real-time online visitors in WordPress website.
You may have seen real-time visitors count on several websites. Blogger has a widget for this. If you also want to add a similar kind of thing to 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 to your WordPress website.
WP-UserOnline is a nice WordPress plugin that lets you achieve this thing in WordPress. It offers an easy way to add a real-time visitors section to your WordPress blog. It also offers detailed statistics at the backend to let you know more about visitors.
Install the 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.
The next step is to create a page where you want to display online users’ stats. Create a new page from the 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 a widget. So, you can add widgets to display the user’s online stats by adding the widget. Find the widget in the Widget section of the 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.