• Resolved raphaelw

    (@raphaelw)


    Hi guys,

    Thank you for this great plugin, i installed it one year ago and it used to work perfectly for me with my custom needs until the last plugin update (5.3.1).

    I run a custom WP_query on my frontpage returning the most popular custom post types (weekly), using this code : How To: Sorting a custom query by views (All time, monthly, weekly, or daily) in my functions.php

    It was working great until last update, but now, the posts displayed are not matching with the most populars anymore.

    My query looks like :

    $args = array('meta_key' => 'views_weekly', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'posts_per_page' => 15, 'post_type' => 'guide');
    $popularPostsQuery = new WP_query( $args );

    And the code in functions.php is :

    function custom_wpp_update_postviews($postid) {
        $accuracy = 30;
        if ( function_exists('wpp_get_views') && (mt_rand(0,100) < $accuracy) ) {
            update_post_meta(
                $postid,
                'views_weekly',
                wpp_get_views($postid, 'weekly', false)
            );
        }
    }
    add_action('wpp_post_update_views', 'custom_wpp_update_postviews');

    Do you have any idea about where this recent issue comes from?

    Thank you

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @raphaelw,

    Glad to know that WPP has been useful to you so thanks for the kind words.

    Regarding your issue, it’s probably related to this. Please give the solution I shared there a try and let me know if it fixes the problem for you.

    Thread Starter raphaelw

    (@raphaelw)

    Hi Héctor,

    Thank you so much, i haven’t seen this post despite my searches.
    Great, it looks like it works again ??

    I temporarily changed the accuracy parameter to 100 in order to see it in action.

    Thanks again for your pretty good work and such nice support!

    Best

    • This reply was modified 3 years, 7 months ago by raphaelw.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom WP_query’ is closed to new replies.