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 today
    • yesterday: Statistics for yesterday
    • day: Daily statistics
    • week: Weekly statistics
    • month: Monthly statistics
    • year: Yearly statistics
    • total: Cumulative statistics
    • x (e.g., -10): Statistics for the past x 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 WordPress
    • English: Uses the 1,000.00 style format
    • none: 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

StatDescription
usersonlineThe number of users online right now.
visitsThe number of hits to the site.
visitorsThe number of visitors to the site.
pagevisitsThe number of times the current page has been visited.
searchesThe number of search engine referrals.
postcountThe total number of posts on the site.
pagecountThe total number of pages on the site.
commentcountThe total number of comments on the site.
spamcountThe total number of spam comments on the site.
usercountThe total number of users on the site.
postaverageThe average posts per user on the site.
commentaverageThe average comments per user on the site.
useraverageThe average number of users on the site.
lpdThe 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]