WordPress.org

Ready to get started?Download WordPress

Forums

WP Slimstat
[resolved] Filter most popular posts (10 posts)

  1. Statistiker
    Member
    Posted 10 months ago #

    Hello,

    I would like to view the most popular posts on my blog per month. Until now I started a wordpress query:

    query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC&ignore_sticky_posts=1&year=' . date( 'Y', current_time( 'timestamp' ) ).'&monthnum=' . date( 'n', current_time( 'timestamp' ) ).'&posts_per_page='. $number_of_posts );

    which worked quite good. Unfortunately the number of post views is about a factor of five lower than the slim stat counts and most importantly some posts are higher ranked, although they were not so frequently visited.

    So to put it in a nutshell I am searching for an easy way to get the top five posts of my blog sorted with respect to slim stat's number of visits. Has anyone done that before and can give me a hint?

    Thank you so much in advance!

    Best regards,

    Martin

    http://wordpress.org/plugins/wp-slimstat/

  2. camu
    Member
    Plugin Author

    Posted 10 months ago #

    Check our FAQs to use our API to do that.

    Best,
    Camu

  3. Statistiker
    Member
    Posted 10 months ago #

    Thank you very much camu!

    My problem is nearly solved but unfortunately there is one last question concerning the API.

    I want to use get_popular with respect to the current month and year only on posts. Somehow I have an error in the syntax because

    wp_slimstat_db::init('content_type equals post AND month equals '.date('n', current_time( 'timestamp' )).' AND year equals '.date('Y', current_time( 'timestamp' )));

    shows no results, while

    wp_slimstat_db::init('content_type equals post');

    and

    wp_slimstat_db::init('month equals '.date('n', current_time( 'timestamp' )));

    work for there own. I am sorry for this stupid question, but could you please tell me, how to use the AND operator in this case?

    Again thanks a lot for this great support!

    Statistiker

  4. camu
    Member
    Plugin Author

    Posted 10 months ago #

    Good point, the FAQs don't say how to concat multiple filters! I will take care of that in version 3.4.1. In the meanwhile, the AND operator is | :

    wp_slimstat_db::init('content_type equals post|month equals '.date('n', current_time( 'timestamp' )).'|year equals '.date('Y', current_time( 'timestamp' )));

    If you don't specify a date range, the API defaults to the current month, so in your case

    wp_slimstat_db::init('content_type equals post');

    is enough.

    A review for SlimStat would be a nice way to say thank you!

  5. Statistiker
    Member
    Posted 10 months ago #

    Thanks that perfectly worked!

  6. camu
    Member
    Plugin Author

    Posted 10 months ago #

    Thank you for your review!

  7. Statistiker
    Member
    Posted 5 months ago #

    Sorry to bother you with an old problem.

    In the last view month I was able to get the most popular post by

    wp_slimstat_db::init('content_type equals post');
    $results = wp_slimstat_db::get_popular('t1.resource');
    foreach ($results as $result)
    {
       ...
    }

    But since a view days ago there is a great discrepancy between the output of the lines above and the top pages part in the report in the dashboard. I guess that some of the last updates might have caused this issue? Currently I am using the version 3.5.7. With 3.5.1 it definitly worked.

    Do I have to specify the date range now when calling init('content_type equals post')? Or has anything else changed? I checked the changelog but found nothing.

    Can I provide you any helpful informations?

    Thanks for your support. It's always great!

  8. camu
    Member
    Plugin Author

    Posted 5 months ago #

    I am looking into this

  9. Statistiker
    Member
    Posted 5 months ago #

    Thank you!

    Since yesterday the bug removed. But I think it's most likely correlated to the change in month. That's also the reason why I asked, whether I have to specify the date range since the last versions. Maybe I should wait till end of April, whether it appears again or not.

    I also don't want to exclude a bug on my side.

    Best regards.

    EDIT: Oh I have something to add. Somehow the

    wp_slimstat_db::init('content_type equals post');

    line is ignoring 'content_type equals post'. It also returns custom post types and pages instead of posts. Maybe there's the bug?

  10. camu
    Member
    Plugin Author

    Posted 5 months ago #

    I'll take a look at the issue.

Reply

You must log in to post.

About this Plugin

About this Topic