WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Filter most popular posts

[Resolved] Filter most popular posts

  • Statistiker
    Member

    @statistiker

    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/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Jason Crouse
    Participant

    @coolmann

    Check our FAQs to use our API to do that.

    Best,
    Camu

    Statistiker
    Member

    @statistiker

    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

    Plugin Author Jason Crouse
    Participant

    @coolmann

    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!

    Statistiker
    Member

    @statistiker

    Thanks that perfectly worked!

    Plugin Author Jason Crouse
    Participant

    @coolmann

    Thank you for your review!

    Statistiker
    Member

    @statistiker

    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!

    Plugin Author Jason Crouse
    Participant

    @coolmann

    I am looking into this

    Statistiker
    Member

    @statistiker

    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?

    Plugin Author Jason Crouse
    Participant

    @coolmann

    I’ll take a look at the issue.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] Filter most popular posts’ is closed to new replies.