Title: Current post&#039;s stats
Last modified: August 20, 2016

---

# Current post's stats

 *  Resolved [Clifford Paulick](https://wordpress.org/support/users/cliffpaulick/)
 * (@cliffpaulick)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/current-posts-stats/)
 * Correct me if I’m wrong, but here’s my understanding, trying out SlimStat for
   the first time:
 * Q: SlimStat plugin doesn’t include a widget with options
    A: SlimStat Shortcodes
   can be used in a text widget to accomplish this
 * Q: SlimStat usage description doesn’t specify a PHP function/code to use to insert
   into a theme to display something like “this current post’s all-time views” or“
   this current post’s views this month”
    A: do_shortcode could be used in PHP to
   accomplish this with SlimStat Shortcodes
 * Assuming I’m understanding everything correctly, what’s the proper shortcode /
   PHP code to use for displaying a current post’s pageviews?
 * I didn’t see it on the [FAQs](http://wordpress.org/extend/plugins/wp-slimstat-shortcodes/faq/).
 * P.S. Some PHP code examples would be nice, like [WP-PostViews provides](http://wordpress.org/extend/plugins/wp-postviews/faq/).
   
   Follow up: Do you know of pros/cons compared to WP-PostViews? SlimStat looks 
   pretty well done. Kudos / Thanks.
 * Thank you very much.

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * (@coolmann)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/current-posts-stats/#post-3389988)
 * Hi Clifford,
 * Support for widgets has been temporarily dropped in version 2.1 because people
   were complaining about performance issues. I’m planning to introduce a proper
   widget, like you hinted here above, which will allow admins to leverage all the
   features by using an intuitive interface. You can manually enable it, though,
   by adding the following code to your functions.php file
 * add_filter(‘widget_text’, ‘do_shortcode’);
 * Right now the only way to show the current post’s stats is by using some PHP 
   code in your single.php:
 *     ```
       if (!class_exists('wp_slimstat_db')) include_once(WP_PLUGIN_DIR.'/wp-slimstat/admin/view/wp-slimstat-db.php');
   
       // Initialize the API. You can pass a filter in the options, i.e. show only hits by people who where using Firefox, any version
       $parsed_permalink = parse_url(get_permalink($post->ID));
       wp_slimstat_db::init('resource equals '.$parsed_permalink['path'].(!empty($parsed_permalink['query'])?$parsed_permalink['query']:''));
   
       // Use the appropriate method to display your stats
       echo wp_slimstat_db::count_records('1=1', '*', true);
       ```
   
 * Please take a look at WP SlimStat’s FAQs for more information on what filters
   and methods are available.
 * [http://wordpress.org/extend/plugins/wp-slimstat/faq/](http://wordpress.org/extend/plugins/wp-slimstat/faq/)
 * PS: a vote for my plugin would be a nice way to say thank you
 *  Thread Starter [Clifford Paulick](https://wordpress.org/support/users/cliffpaulick/)
 * (@cliffpaulick)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/current-posts-stats/#post-3389992)
 * Thanks.
 * I did add the shortcodes in the widget (requires adding shortcode support to 
   widgets in functions.php), which worked well.
 * However, having the plugins active for an hour or so, I saw the top 3 of top 
   5 posts were the same because posts were like post-title?fb_ref_exp and ?facebook_edf(
   just made those up, can’t remember what they were).
 * For a front-end display, I’d want those consolidated. I thought the plugin would
   track per-post not per-URI stats. Am I missing something?
 * Thank you.
 *  Plugin Author [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * (@coolmann)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/current-posts-stats/#post-3389994)
 * well, then you can use ‘contains’ instead of ‘equals’ as the operator in the 
   init:
 * `resource contains ....`
 * The plugin tracks per-URI because otherwise how would you store the information
   for categories, custom post type archives and other stuff that is not easily 
   identified by an ID? 🙂
 * Camu
 * PS: I revisited the PHP code in my message here above to remove a few typos.
 *  Thread Starter [Clifford Paulick](https://wordpress.org/support/users/cliffpaulick/)
 * (@cliffpaulick)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/current-posts-stats/#post-3389995)
 * Gotcha.
 * Maybe I missed it, but is there a shortcode for displaying “this post’s views”?
 * In other words, I don’t care if they visited the post last year when my permalink
   structure was different, I just want to know how many views this post/ID has 
   achieved.
 * Thanks.
 *  Plugin Author [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * (@coolmann)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/current-posts-stats/#post-3389996)
 * Nope, sorry. What you can do is to count all the pageviews for each given permalink
   structure, and then add them up.
 * Also, by default the library assumes you want this month’s views, if you want
   to count from the beginning, you’ll have to change your code to:
 * `echo wp_slimstat_db::count_records('1=1', '*', true, '', false);`
 * Thanks,
    Camu
 *  Thread Starter [Clifford Paulick](https://wordpress.org/support/users/cliffpaulick/)
 * (@cliffpaulick)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/current-posts-stats/#post-3389997)
 * Ok. Bummer. Thanks. Due to that one limitation, I think I’ll be picking another
   stats plugin. But I really appreciate the sophistication and detail of this one;
   I just don’t need it for my current site.
 * Best to you. 🙂
 *  Plugin Author [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * (@coolmann)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/current-posts-stats/#post-3390001)
 * You actually gave me a great idea for a new functionality to add to SlimStat 
   😉 I will be adding posts and pages IDs to the database starting from the next
   version, so that you will be able to do what you were looking for. Happy?
 * Don’t I deserve a vote for that 😀
 * Cheers,
    Camu
 *  Thread Starter [Clifford Paulick](https://wordpress.org/support/users/cliffpaulick/)
 * (@cliffpaulick)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/current-posts-stats/#post-3390002)
 * Nice. I’ll vote for you. Any idea when? Really looking forward to it.
 *  Plugin Author [Jason Crouse](https://wordpress.org/support/users/coolmann/)
 * (@coolmann)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/current-posts-stats/#post-3390003)
 * I can send you the unstable beta, if you want, so that you can already test it
   😉
 * Cheers,
    Camu
 *  Thread Starter [Clifford Paulick](https://wordpress.org/support/users/cliffpaulick/)
 * (@cliffpaulick)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/current-posts-stats/#post-3390004)
 * Well that’s pretty darn quick… I’d rather wait for the stable version for my 
   current needs, but if you want to send it anyways, that’s fine. Post a link here
   or email tko -at- tourkick.com
 * Thanks so much.
 *  [rockwildaz](https://wordpress.org/support/users/rockwildaz/)
 * (@rockwildaz)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/current-posts-stats/#post-3390167)
 * Any update on this request? I too need a shortcode to show current post’s views.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Current post's stats’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-slimstat-shortcodes.svg)
 * [WP SlimStat Shortcodes](https://wordpress.org/plugins/wp-slimstat-shortcodes/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-slimstat-shortcodes/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-slimstat-shortcodes/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-slimstat-shortcodes/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-slimstat-shortcodes/reviews/)

 * 11 replies
 * 3 participants
 * Last reply from: [rockwildaz](https://wordpress.org/support/users/rockwildaz/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/current-posts-stats/#post-3390167)
 * Status: resolved