Plugin Directory

WP SlimStat Shortcodes

Adds support for shortcodes to WP SlimStat

What is a shortcode?

A shortcode is sort of a placeholder: a special string that will be replaced by dynamic content.

What do shortcodes look like?

[slimstat f='FUNC' w='WHAT_COLUMN' lf='FILTERS' s='SEP']


  • f [required] is the criteria to be used (count results, get popular or recent items)
  • w [required] defines what dataset you want to retrieve (browser, language, resource; here below you can find a complete list of columns)
  • lf [optional] specifies what conditions to use while retrieving the data (browser equals Firefox, country equals China); if the value starts with WHERE:, the string that follows will be used verbatim in the SQL query
  • lc [optional, default: WHAT_COLUMN] tells the plugin what data to return; it defaults to the column specified in w
  • s [optional] sets the character or string used to "separate" each piece of information in a row (defaults to <span class='slimstat-item-separator'>,</span>)

Frequently used codes

  • Pageviews Today: [slimstat f='count' w='ip' lf='day equals today']
  • Unique Human Visitors Today: [slimstat f='count' w='ip' lf='day equals today&&&visit_id is_greater_than 0']
  • Currently Online: [slimstat f='count-all' w='ip' lf='WHERE:NOW() - dt < 300']
  • Count all pageviews from the beginning: [slimstat f='count-all' w='*']
  • Popular pages (this month): [slimstat f='popular' w='resource' lf='content_type equals post' lc='post_link,count']
  • Recent searches: [slimstat f='recent' w='searchterms']
  • Most active visitors: [slimstat f='popular' w='user' lc='user,count']

Available functions

  • count and count-all return a number
  • recent and popular return a bulleted list of elements
  • custom, used along with WHERE to run a custom SQL query - i.e. lf='WHERE:SELECT * FROM wp_slim_stats t1...'; it returns a list of elements

Available keys (WHAT_COLUMN)

  • browser: user agent (Firefox, Chrome, ...)
  • content_type: post, page, custom-post-type, attachment, singular, post_type_archive, tag, taxonomy, category, date, author, archive, search, feed, home; please refer to the Conditional Tags manual page for more information
  • country: 2-letter code (us, ru, de, it, ...)
  • domain: domain name of the referring page (i.e., http://www.google.com if a visitor came from Google)
  • language: please refer to the language culture names (first column) for more information
  • platform: operating system; it accepts identifiers like win7, win98, macosx, ...; please refer to this manual page for more information about these codes
  • referer: complete URL of the referring page
  • searchterms: search term used to find your website on a search engine
  • user: visitor's name according to the cookie set by WordPress after s/he left a comment

How do I filter the data returned by your plugin?

A filter consists of three elements: the key, the condition and the value. For example, if you want to display your 20 most popular posts visited by people coming from Italy, your key is country, your condition is equals and your value is it (Country code for Italy). You can combine multiple keys/values to further narrow down your results.

Available filters

  • all the keys listed above
  • author: WordPress author associated to that post/page when the resource was accessed
  • browser: user agent (Firefox, Chrome, ...)
  • version: user agent version (9.0, 11, ...)
  • category: ID of the category/term associated to the resource, when available
  • css_version: what CSS standard was supported by that browser (1, 2, 3 and other integer values)
  • colordepth: visitor's screen's color depth (8, 16, 24, ...)
  • ip: visitor's public IP address
  • other_ip: visitor's private IP address, if available
  • resolution: viewport width and height (1024x768, 800x600, ...)
  • resource: URL accessed on your site
  • type: (browser) 1 = search engine crawler, 2 = mobile device, 3 = syndication reader, 0 = all others
  • direction: asc or desc (lowercase)
  • limit_results: max number of results returned
  • starting: return results starting from a given offset

Can I use date ranges?

Yes you can! By default shortcodes return data related to the current month, but you can specify a different start date and the interval in your filters (along with the equals operator):

  • day (default: 1)
  • month (default: current month)
  • year (default: current year)
  • strtotime, use it if you want the plugin to use PHP's strtotime function to calculate a specific date for you (yesteday, this month, last year, 3 weeks ago)
  • interval, to fix the number of days from the start date (for example, ten days starting from January 14th); please make sure to define interval after the start date!
    • if both day or strtotime are set, the default value is zero
    • if neither day nor strtotime are set, the default value is the number of days in the current month
    • you can use -1 to indicate the number of days between the start date and today (in other words, to describe date ranges like 'Year to date', you can set day equals 1,month equals 1,interval equals -1)

You can use natural language for day, month and year: day equals today, year equals last year, etc. The plugin will try to apply strtotime (see link here above) to your value.

What conditional operators are available? (note: words are separated by underscores, not blank spaces!)

  • equals
  • is_not_equal_to
  • contains
  • does_not_contain
  • starts_with
  • ends_with
  • sounds_like
  • is_greater_than
  • is_less_than
  • is_empty (followed by a blank space and the # sign: searchterms is_empty #&&&month equals 5)
  • is_not_empty (followed by a blank space and the # sign: searchterms is_not_empty #&&&browser contains fire)

How do I combine keys and values to create filters?

In order to simplify things, WP SlimStat Shortcodes implements a 'natural language' approach. For example, let's say you want to obtain your blog's 5 most popular posts. This is what the shortcode will look like:

[slimstat f='popular' w='resource' lf='content_type equals post&&&limit_results equals 5' lc='post_link,count']

Curious about what your visitors where searching for, before landing on your blog?

[slimstat f='recent' w='searchterms']

Do you want to target a specific language? What about listing the 20 most recent Chinese-speaking IP addresses who accessed just your homepage:

[slimstat f='recent' w='ip' lf='content_type equals home&&&language equals zh-cn&&&limit_results equals 20']

Do you need just to count how many pageviews have been generated during the current month? (by default all shortcodes use the current month as date range)

[slimstat f='count' w='*']

Maybe this year?

[slimstat f='count' w='*' lf='strtotime equals 1 January&&&interval equals -1']

The first 5 days of January?

[slimstat f='count' w='*' lf='day equals 1&&&month equals 1&&&interval equals 5']

From the beginning (all pageviews recorded so far)

[slimstat f='count-all' w='*']

Unique IPs (unique visitors):

[slimstat f='count' w='ip']

Unique Visits this month:

[slimstat f='count' w='visit_id']

Things can easily get fancy

  • [slimstat f='popular' w='searchterms' lf='searchterms contains pizza dough' lc='searchterms,count']

Available columns (lc)

  • all the keys listed here above, separated by commas
  • count, available only when using popular, represents the number of pageviews matching your query
  • dt, combined with recent, can be used to display date and time of each pageview (it uses your WordPress settings for date and time format)
  • hostname, to convert IP addresses into hostnames, using PHP's gethostbyaddr
  • post_link, returns post titles linked to their corresponding permalinks

Requires: 3.8 or higher
Compatible up to: 4.2
Last Updated: 2015-2-14
Active Installs: 5,000+


4.6 out of 5 stars


3 of 4 support threads in the last two months have been resolved.

Got something to say? Need help?


Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 0,1,0
0,1,0 0,1,0
0,1,0 0,1,0 50,2,1 100,1,1