Shortcodes

WP Statistics supports shortcodes in WordPress, these can be used in either a post and page body as well as an HTML widget.

The general shortcode format is:

[wpstatistics stat=xxx time=xxxx provider=xxxx format=xxxxxx id=xxx]

Where:

Item

Description

stat

The statistic you want, see the next table for available options.

time

Is the time frame for the statistic.  This value uses the strtotime() PHP function (http://php.net/manual/en/datetime.formats.php) format, some acceptable values include:

  • today 

  • yesterday 

  • week 

  • month 

  • year 

  • total  

  • “-x” (i.e., “-10” for the past 10 days) 

Please refer to the PHP manual link above for a complete description.

provider

The search provider to get stats on (ask/bing/clearch/duckduckgo/google/yahoo/yandex).

format

The format to use for numbers, the options are i18n (uses the format of the current country as set in WordPress), english (uses 1,000.00 style formats) or none (the default will return an number without any formating)

Id

The page/post ID to get statistics on.  Only used on pagevisits.

 

The “stat” field can be any of the following:

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:

[wpstatistics stat=usersonline]
[wpstatistics stat=visitors time=today]
[wpstatistics stat=visits time=today]
[wpstatistics stat=visitors time=yesterday]
[wpstatistics stat=visits time=yesterday]
[wpstatistics stat=visitors time=total]
[wpstatistics stat=visits time=total]