How to install
- Upload the plugin to your blog and activate
- Visit the settings to configure your options
More info on installing WP plugins
How to use
Visit the plugin settings page to configure your shortcodes. Then copy/paste the shortcodes in any Post, Page, or Widget to display your stats. To display your stats anywhere in your theme template, visit the “Template Tags” section of the settings page.
Meet the shortcodes
Visit the plugin settings page for a complete list of shortcodes. There you may customize the output of each shortcode. Here is a list of all SBS shortcodes:
[sbs_posts] = number of posts *
[sbs_posts_alt] = number of posts *
[sbs_pages] = number of pages
[sbs_drafts] = number of drafts
[sbs_comments] = number of comments *
[sbs_moderated] = moderated comments
[sbs_approved] = approved comments *
[sbs_users] = number of users
[sbs_cats] = number of categories
[sbs_tags] = number of tags *
[sbs_tax tax="tax_name"] = number of taxonomy terms
[sbs_tax_posts ...] = number of posts for tax term(s) *
[sbs_word_count] = number of words in post *
[sbs_word_count_all] = number of words in all posts (all post types) *
[sbs_word_count_custom] = number of words in custom field *
[sbs_updated] = site last updated *
[sbs_latest_posts] = displays recent posts
[sbs_latest_comments] = displays recent comments
[sbs_roles] = number of users per role *
[sbs_cpts_count] = list of CPT counts
[sbs_cpt_count cpt="post"] = number of any post type
[sbs_blog_stats] = displays list of blog stats
[sbs_logged_users] = number of logged-in users *
[sbs_media_count] = number of media files *
[sbs_reading_time] = estimated reading time
* See notes below.
[sbs_posts]
The [sbs_posts] shortcode accepts several attributes that can be used to customize your post stats:
cat - limit by category (default: empty = all cats)
tag - limit by tag (default: empty = all tags)
type - limit by post type (default: empty = post)
status - limit by post status (default: empty = publish)
exclude - exclude post IDs (comma separated list of post IDs)
exclude_cat - exclude categories (comma separated list of category IDs)
number_format - thousands separator (default: comma, like 1,234)
So by default, [sbs_posts] with no attributes will display the total number of published posts in any category or tag.
Here is an example that makes use of the attributes:
[sbs_posts cat="sci-fi" tag="sequel" type="movie" status="draft"]
That will display all drafts of the custom post type “movie” that are in the “sci-fi” category and tagged as “sequel”.
To display post count for multiple categories, separate category slugs with commas, like [sbs_posts cat="cat-1,cat-2,cat-3"].
More information about the possible values for these attributes:
[sbs_posts_alt]
The [sbs_posts_alt] shortcode is for sites with LOTS of posts (like 10,000+). It is not as flexible as [sbs_posts], but does provide several attributes:
[sbs_posts_alt type="page" status="draft" number_format=","]
You can change the type and status of the posts that should be counted. The number_format attribute determines the separator for large numbers. Again, this shortcode should be used only for sites with extreme numbers of posts.
[sbs_updated]
The [sbs_updated] shortcode outputs the date and time of the latest post. It accepts two attributes, format_date and format_time, that enable you to customize the format of the output date and time, respectively. Here are some examples to show how it works:
[sbs_updated format_date="Y/m/d"] = custom format for date, default format for time
[sbs_updated format_time="H:i:s"] = custom format for time, default format for date
[sbs_updated format_date="Y/m/d" format_time="disable"] = custom format for date, disable time output
[sbs_updated format_date="Y/m/d" format_time="H:i:s"] = custom format for both date and time
For the attribute values, you can use any valid PHP date/time format. Check the PHP docs for a complete list of available formats.
[sbs_comments]
By default, the [sbs_comments] shortcode displays the total number of comments for all posts on your site. To display the number of comments only for a specific category, add the cat attribute, like so:
[sbs_comments cat="1"]
You can change the category ID to display number of comments for any category.
[sbs_approved]
By default, the [sbs_approved] shortcode displays the total number of comments that have been approved/published. This shortcode provides an optional attribute to specify the number format:
[sbs_approved number_format=","]
You can change the number format to whatever makes sense for your site.
[sbs_tags]
By default, the [sbs_tags] shortcode displays the total number of tags that have been created. This shortcode provides an optional attribute to specify the number format:
[sbs_tags number_format=","]
You can change the number format to whatever makes sense for your site.
[sbs_tax_posts]
The [sbs_tax_posts] shortcode displays the number of posts that belong to a specific post type and taxonomy term(s). Here is an example:
[sbs_tax_posts tax="taxonomy" terms="term-1, term-2, term-3" type="custom-post-type"]
Then change the attribute values to match your taxonomy, terms, and post type, respectively.
[sbs_word_count]
The [sbs_word_count] shortcode displays the number of words in post content. By default it displays number of words in the current post. Or you can specify any post ID:
[sbs_word_count] // displays word count of current post
[sbs_word_count id="1"] // displays word count of post with ID = 1
[sbs_word_count number_format=","] // displays word count with comma separator
To display the word count for all posts (any post type), use the shortcode [sbs_word_count_all]. Check the FAQs to customize the post type for this shortcode.
[sbs_word_count_custom]
The [sbs_word_count_custom] shortcode displays the number of words in any custom field. It requires a post ID and name of a custom field. Here is an example:
[sbs_word_count_custom post_id="12" key="author-bio"]
So if post ID = 12 has a custom field named “author-bio”, this shortcode will return the number of words contained in the custom field (not the post).
[sbs_roles]
The [sbs_roles] shortcode displays a list of all user roles and corresponding number of users. To display the number of users for a specific role, add the role attribute. Examples:
[sbs_roles] // displays list of roles and number of users
[sbs_roles role="author"] // displays number of users for specified role
[sbs_roles role="all"] // displays list of roles and number of users
The role attribute accepts a value of all or any valid user role.
[sbs_cpt_count]
The [sbs_cpt_count] shortcode displays the number of posts for the specified post type. For example, if you want to display the number of posts for a post type called food, would like this:
[sbs_cpt_count cpt="food"]
The default post type for this shortcode is post. The [sbs_cpt_count] shortcode accepts three attributes that can be used to customize:
cpt - specifies the post type
txt - specifies custom label/name
number_format - thousands separator (default: comma, like 1,234)
By default, [sbs_cpt_count] with no attributes will display the total number of published posts.
[sbs_logged_users]
The [sbs_logged_users] shortcode can be used to display the number of currently logged-in users. This shortcode does not have any attributes, but does provide a widget that displays the current logged-in user count on the WP Dashboard.
[sbs_media_count]
The [sbs_media_count] shortcode can display stats for any media type(s). Here are some examples:
[sbs_media_count type="all"] = displays number of all media files
[sbs_media_count type="image"] = displays number of image files
[sbs_media_count type="video"] = displays number of video files
[sbs_media_count type="pdf,doc,docx"] = displays number of PDF, DOC, and DOCX files
[sbs_media_count type="mp3"] = displays number of MP3 files
[sbs_media_count] = displays number of all media files
Customize output
Most of the shortcodes display only a number. To customize the number with your own text, visit the plugin settings. There you can add any text or markup that should be displayed before/after each shortcode.
There are three shortcodes that output some default text along with the stats number:
[sbs_roles]
[sbs_cpt_count]
[sbs_media_count]
So to customize the text for these shortcodes, you can add a txt attribute and set the value to whatever you want, for example:
[sbs_roles txt="Whatever you want"]
[sbs_cpt_count txt="Whatever you want"]
[sbs_media_count txt="Whatever you want"]
Or if you want to just disable the extra text and display only the number, set the txt attribute to null, like so:
[sbs_roles txt="null"]
[sbs_cpt_count txt="null"]
[sbs_media_count txt="null"]
That way only the number will be displayed without any other text.
Like the plugin?
If you like Simple Blog Stats, please take a moment to give a 5-star rating. It helps to keep development and support going strong. Thank you!
Restore Default Options
To restore default plugin options, either uninstall/reinstall the plugin, or visit the plugin settings > Restore Default Options.
Uninstalling
This plugin cleans up after itself. All plugin settings will be removed from the WordPress database when the plugin is deleted via the WP Plugins screen. Note: any shortcodes that you have added to your posts and pages will not be removed. Likewise any template tags that have been added to your theme template will not be removed.