• Resolved Clifford Paulick

    (@cliffpaulick)


    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.

    P.S. Some PHP code examples would be nice, like WP-PostViews provides.
    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

    (@coolmann)

    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

    Thread Starter Clifford Paulick

    (@cliffpaulick)

    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

    (@coolmann)

    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

    (@cliffpaulick)

    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

    (@coolmann)

    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

    (@cliffpaulick)

    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

    (@coolmann)

    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

    (@cliffpaulick)

    Nice. I’ll vote for you. Any idea when? Really looking forward to it.

    Plugin Author Jason Crouse

    (@coolmann)

    I can send you the unstable beta, if you want, so that you can already test it 😉

    Cheers,
    Camu

    Thread Starter Clifford Paulick

    (@cliffpaulick)

    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.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Current post's stats’ is closed to new replies.