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/
PS: a vote for my plugin would be a nice way to say thank you
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.
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.
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.
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
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. 🙂
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
Nice. I’ll vote for you. Any idea when? Really looking forward to it.
I can send you the unstable beta, if you want, so that you can already test it 😉
Cheers,
Camu
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.
Any update on this request? I too need a shortcode to show current post’s views.