• Resolved lastnoob

    (@lastnoob)


    This is a great plugin, thank you!

    I couldn’t find in the docs how to get an array of posts or an object returned with wpp_get_mostpopular(). I’d like to loop through them myself instead of straight up rendering them. Is this possible?

    Would be great if there was a way to build a WP_Query.

    I tried this, but doesn’t seem to work, it throws a different result compared to wpp_get_mostpopular() with the same params:

    if ( function_exists('wpp_get_mostpopular') ) {
    
    /* Get up to the top 5 commented posts from the last 7 days */
    
    /* $trending_posts = wpp_get_mostpopular(array(
    
    'limit' => 4,
    
    'range' => 'last30days',
    
    'order_by' => 'views'
    
    )); */
    
    $args = array(
    
    'range' => 'last30days',
    
    'posts_per_page' => 4,
    
    'post_type' => 'post',
    
    'order_by' => 'views',
    
    'limit' => 4
    
    );
    
    $trending_posts = new WP_Query( $args );
    
    }

    Thanks in advance!

    • This topic was modified 11 months, 1 week ago by lastnoob.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to get an array or object with wpp_get_mostpopular?’ is closed to new replies.