Documentation Functions Shortcodes
Shortcodes
With WP Statistics, you can display different statistics using shortcodes in posts, pages, and HTML widgets.
General Shortcode Format
To use WP Statistics shortcodes, follow the format below:
[wpstatistics stat={stat} time={time} provider={provider} format={format} id={id}]
Parameters
- stat: (Required) Specifies the statistic you want to display. Refer to the table in the “Stat Options” section for available values.
- time: (Optional) Defines the time period for the statistic. Acceptable values include:
today
: Statistics for todayyesterday
: Statistics for yesterdayday
: Daily statisticsweek
: Weekly statisticsmonth
: Monthly statisticsyear
: Yearly statisticstotal
: Cumulative statisticsx
(e.g.,-10
): Statistics for the pastx
days (e.g.,-10
for the past 10 days)
This parameter uses the strtotime()
PHP function. For more details, visit the PHP manual.
- provider: (Optional) The search engine provider for search stats. Acceptable values include:
ask
bing
clearch
duckduckgo
google
yahoo
yandex
- format: (Optional) Specifies the format for the displayed numbers. Options include:
i18n
: Uses the format of the current country as set in WordPressEnglish
: Uses the 1,000.00 style formatnone
: Returns numbers without any formatting (default)
- id: (Optional) The ID of the page or post to get statistics for. This parameter is only applicable for page visits.
Example Usage
To display the number of visitors today:
[wpstatistics stat=visitors time=today]
To display the total number of visits:
[wpstatistics stat=visits time=total]
Using these parameters, you can customize the shortcodes to fit your specific needs and display a wide range of statistics on your WordPress site.
Stat Options
Stat | Description |
---|---|
usersonline | The number of users online right now. |
visits | The number of hits to the site. |
visitors | The number of visitors to the site. |
pagevisits | The number of times the current page has been visited. |
searches | The number of search engine referrals. |
postcount | The total number of posts on the site. |
pagecount | The total number of pages on the site. |
commentcount | The total number of comments on the site. |
spamcount | The total number of spam comments on the site. |
usercount | The total number of users on the site. |
postaverage | The average posts per user on the site. |
commentaverage | The average comments per user on the site. |
useraverage | The average number of users on the site. |
lpd | The last post date for the site. |
Examples
Below are examples of how to use the shortcodes:
- To get the number of users online right now:
[wpstatistics stat=usersonline]
- To get the number of visitors today:
[wpstatistics stat=visitors time=today]
- To get the number of visits today:
[wpstatistics stat=visits time=today]
- To get the number of visits yesterday:
[wpstatistics stat=visits time=yesterday]
- To get the total number of visits:
[wpstatistics stat=visits time=total]
- To get the total number of visitors:
[wpstatistics stat=visitors time=total]