Below, you’ll find a detailed guide on how to add the Visitor Traffic Real Time Statistics Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Visitor Traffic Real Time Statistics Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Visitor Traffic Real Time Statistics Plugin and the shortcodes it provides:
"Visitor Traffic Real Time Statistics is a dynamic WordPress plugin that allows you to monitor and analyze your website's traffic data in real-time. Track visitor activities, page views, and much more."
- [ahc_stats_widget]
- [ahc_today_visitors]
- [ahc_today_visits]
- [ahc_total_visitors]
- [ahc_total_visits]
- [ahc_yesterday_total_visits]
- [ahc_yesterday_total_visitors]
Visitor Traffic Real Time Statistics [ahc_stats_widget] Shortcode
The ‘ahc_stats_widget’ shortcode from the Visitors Traffic Real-Time Statistics plugin displays a widget with visitor statistics. It retrieves and displays today’s visitors, page views, and total visitors. This shortcode allows customization of the widget’s title, font size, and type. It also provides the option to hide or display specific statistics. The displayed data is updated in real-time, providing an accurate snapshot of your website’s traffic.
Shortcode: [ahc_stats_widget]
Parameters
Here is a list of all possible ahc_stats_widget shortcode parameters and attributes:
fontsize
– Sets the font size of the statistics texttitle
– Sets the title of the statistics widgetfonttype
– Sets the font type of the statistics textdisplay_today_visitors
– If set to true, displays today’s visitors countdisplay_today_pageviwes
– If set to true, displays today’s page views countdisplay_total_visitors
– If set to true, displays the total visitors countdisplay_total_pageviwes
– If set to true, displays the total page views count
Examples and Usage
Basic example – Displaying the basic statistics with default parameters.
[ahc_stats_widget /]
Advanced examples
Displaying the statistics with a specific title and font size.
[ahc_stats_widget title="My Website Statistics" fontsize=16 /]
Displaying only today’s visitors and page views, hiding total visitors and page views.
[ahc_stats_widget display_total_visitors=false display_total_pageviwes=false /]
Displaying all statistics with a specific font type.
[ahc_stats_widget fonttype="Arial" /]
Displaying only total visitors and page views, hiding today’s visitors and page views.
[ahc_stats_widget display_today_visitors=false display_today_pageviwes=false /]
PHP Function Code
In case you have difficulties debugging what causing issues with [ahc_stats_widget]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ahc_stats_widget', 'ahc_stats_widget_func');
Shortcode PHP function:
function ahc_stats_widget_func( $instance = [] )
{
$args = shortcode_atts( array(
'fontsize' => '14',
'title' => '',
'fonttype' => '',
'display_today_visitors' => "true",
'display_today_pageviwes' => "true",
'display_total_visitors' => "true",
'display_total_pageviwes' => "true"
), $instance );
$ret = '';
$ahc_sum_stats = ahcfree_get_summary_statistics();
$ret .= isset($args['title']) ? '<h3 class="ahc_stats_widget_title">'.esc_html( $args['title']).'</h3>' : '';
// This is where you run the code and display the output
$ret .= '<ul class="ahc_stats_widget" style="list-style:none; font-family: '.esc_attr($args['fonttype']).' !important; font-size:' . esc_attr($args['fontsize']) . 'px !important">';
if ($args['display_today_visitors'] != 'false' && $args['display_today_visitors'] != false) {
$ret .= '<li><b>'.__("Today's visitors:", 'visitors-traffic-real-time-statistics') .'</b><span>' . ahcfree_NumFormat(intval($ahc_sum_stats['today']['visitors'])) . '</span></li>';
}
if ($args['display_today_pageviwes'] != 'false' && $args['display_today_pageviwes'] != false) {
$ret .= '<li><b>'.__("Today's page views", 'visitors-traffic-real-time-statistics') .' </b><span>' . ahcfree_NumFormat(intval($ahc_sum_stats['today']['visits'])) . '</span></li>';
}
if ($args['display_total_visitors'] !='false' && $args['display_total_visitors'] !=false) {
$ret .= '<li><b>'.__("Total visitors", 'visitors-traffic-real-time-statistics') .' </b><span>' . ahcfree_NumFormat(intval($ahc_sum_stats['total']['visitors'])) . '</span></li>';
}
if ($args['display_total_pageviwes'] !='false' && $args['display_total_visitors'] !=false) {
$ret .= '<li><b>'.__("Total page views", 'visitors-traffic-real-time-statistics') .' </b><span>' . ahcfree_NumFormat(intval($ahc_sum_stats['total']['visits'])) . '</span></li>';
}
$ret .= '</ul>';
return $ret;
}
Code file location:
visitors-traffic-real-time-statistics/visitors-traffic-real-time-statistics/functions.php
Visitor Traffic Real Time Statistics [ahc_today_visitors] Shortcode
The ‘ahc_today_visitors’ shortcode is a part of the Visitors Traffic Real-Time Statistics plugin. It displays the total number of visitors for the current day. The PHP function ‘ahc_today_visitors_func’ retrieves the visitor count using ‘ahcfree_get_visitors_visits_in_period’ function. It then formats the number using ‘ahcfree_NumFormat’ before returning it.
Shortcode: [ahc_today_visitors]
Examples and Usage
Basic example – The following shortcode will display the number of visitors for the current day on your website.
[ahc_today_visitors]
PHP Function Code
In case you have difficulties debugging what causing issues with [ahc_today_visitors]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ahc_today_visitors', 'ahc_today_visitors_func');
Shortcode PHP function:
function ahc_today_visitors_func()
{
$ahc_sum_stats = ahcfree_get_visitors_visits_in_period('today');
return ahcfree_NumFormat(intval($ahc_sum_stats['visitors']));
}
Code file location:
visitors-traffic-real-time-statistics/visitors-traffic-real-time-statistics/functions.php
Visitor Traffic Real Time Statistics [ahc_today_visits] Shortcode
The ‘ahc_today_visits’ shortcode from the Visitors Traffic Real Time Statistics plugin provides the total visitor count for the current day. This shortcode retrieves today’s visitor data using the ‘ahcfree_get_visitors_visits_in_period’ function. It then formats the number for easy readability using the ‘ahcfree_NumFormat’ function.
Shortcode: [ahc_today_visits]
Examples and Usage
Basic example – A simple usage of the shortcode to display the number of today’s visits on your website.
[ahc_today_visits /]
Advanced examples
Since the given shortcode does not accept any parameters, we can not create an advanced example with multiple parameters. However, we can show how to use this shortcode within a PHP file or a template file in your WordPress theme.
Embed the shortcode within a PHP file to display today’s visits on a specific part of your website. This can be useful if you want to integrate the visits count into a custom design or layout.
<?php echo do_shortcode('[ahc_today_visits /]'); ?>
Include the shortcode within a WordPress post or page using the Shortcode Block. This allows you to easily display today’s visits anywhere within your content.
[ahc_today_visits /]
PHP Function Code
In case you have difficulties debugging what causing issues with [ahc_today_visits]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ahc_today_visits', 'ahc_today_visits_func');
Shortcode PHP function:
function ahc_today_visits_func()
{
$ahc_sum_stats = ahcfree_get_visitors_visits_in_period('today');
return ahcfree_NumFormat(intval($ahc_sum_stats['visits']));
}
Code file location:
visitors-traffic-real-time-statistics/visitors-traffic-real-time-statistics/functions.php
Visitor Traffic Real Time Statistics [ahc_total_visitors] Shortcode
The ‘ahc_total_visitors’ shortcode is a function that displays the total number of visitors to your WordPress site. The PHP code retrieves visitor data from a specified period and formats the number for easy reading.
Shortcode: [ahc_total_visitors]
Examples and Usage
Basic example – Show total visitors on your website
[ahc_total_visitors]
PHP Function Code
In case you have difficulties debugging what causing issues with [ahc_total_visitors]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ahc_total_visitors', 'ahc_total_visitors_func');
Shortcode PHP function:
function ahc_total_visitors_func()
{
$ahc_sum_stats = ahcfree_get_visitors_visits_in_period('total');
return ahcfree_NumFormat(intval($ahc_sum_stats['visitors']));
}
Code file location:
visitors-traffic-real-time-statistics/visitors-traffic-real-time-statistics/functions.php
Visitor Traffic Real Time Statistics [ahc_total_visits] Shortcode
The ‘ahc_total_visits’ shortcode from the Visitor Traffic Real Time Statistics plugin retrieves the total number of visits to your website. This shortcode executes the ‘ahc_total_visits_func’ function, which calls the ‘ahcfree_get_visitors_visits_in_period’ function with ‘total’ as a parameter. It then formats the total visit count for display.
Shortcode: [ahc_total_visits]
Examples and Usage
Basic example – The shortcode displays the total number of visits on the website.
[ahc_total_visits /]
PHP Function Code
In case you have difficulties debugging what causing issues with [ahc_total_visits]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ahc_total_visits', 'ahc_total_visits_func');
Shortcode PHP function:
function ahc_total_visits_func()
{
$ahc_sum_stats = ahcfree_get_visitors_visits_in_period('total');
return ahcfree_NumFormat(intval($ahc_sum_stats['visits']));
}
Code file location:
visitors-traffic-real-time-statistics/visitors-traffic-real-time-statistics/functions.php
Visitor Traffic Real Time Statistics [ahc_yesterday_total_visits] Shortcode
The Visitors Traffic Real Time Statistics plugin shortcode, ‘ahc_yesterday_total_visits’, is used to display the total number of website visits from the previous day. The PHP function ‘ahc_yesterday_total_visits_func’ retrieves visitor statistics for ‘yesterday’ and formats the number for display.
Shortcode: [ahc_yesterday_total_visits]
Examples and Usage
Basic example – Display the total number of visits from yesterday.
[ahc_yesterday_total_visits]
PHP Function Code
In case you have difficulties debugging what causing issues with [ahc_yesterday_total_visits]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ahc_yesterday_total_visits', 'ahc_yesterday_total_visits_func');
Shortcode PHP function:
function ahc_yesterday_total_visits_func()
{
$ahc_sum_stats = ahcfree_get_visitors_visits_in_period('yesterday');
return ahcfree_NumFormat(intval($ahc_sum_stats['visits']));
}
Code file location:
visitors-traffic-real-time-statistics/visitors-traffic-real-time-statistics/functions.php
Visitor Traffic Real Time Statistics [ahc_yesterday_total_visitors] Shortcode
The ‘ahc_yesterday_total_visitors’ shortcode is a part of the Visitors Traffic Real-Time Statistics plugin. It displays the total number of visitors from the previous day. The shortcode’s PHP function, ‘ahc_yesterday_total_visitors_func’, retrieves visitor data from ‘yesterday’ and returns this in a formatted number.
Shortcode: [ahc_yesterday_total_visitors]
Examples and Usage
Basic example – A simple shortcode to display yesterday’s total visitors on your website.
[ahc_yesterday_total_visitors]
PHP Function Code
In case you have difficulties debugging what causing issues with [ahc_yesterday_total_visitors]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ahc_yesterday_total_visitors', 'ahc_yesterday_total_visitors_func');
Shortcode PHP function:
function ahc_yesterday_total_visitors_func()
{
$ahc_sum_stats = ahcfree_get_visitors_visits_in_period('yesterday');
return ahcfree_NumFormat(intval($ahc_sum_stats['visitors']));
}
Code file location:
visitors-traffic-real-time-statistics/visitors-traffic-real-time-statistics/functions.php
Conclusion
Now that you’ve learned how to embed the Visitor Traffic Real Time Statistics Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply