• Resolved wpman

    (@iwpman)


    I want to get top 10 post within 4 hours from my custom post type “books”.
    This is my code,but it doesn’t work.

    //args
    $settings = array(
    'hour_range' => 4,
    'limit' => 10,
    'strict_limit' => FALSE,
    'post_types'=>'books',
    );
    $topposts = get_tptn_pop_posts( $settings );
    $topposts = wp_list_pluck( $topposts, 'postnumber' );
    $args = array(
    'post__in' => $topposts,
    'orderby' => 'post_in',
    'posts_per_page' => 10,
    'ignore_sticky_posts' => 1,

    );

    $my_query=new WP_Query($args);
    if($my_query->have_posts()){
    while($my_query->have_posts()){
    $my_query->the_post();
    echo get_the_title();
    wp_reset_postdata();
    }
    }else{}
    wp_reset_query();

    https://ww.wp.xz.cn/plugins/top-10/

Viewing 1 replies (of 1 total)
  • Plugin Author WebberZone

    (@webberzone)

    You might need to try 'post_types' => 'books=books'

    Or alternatively, push the post_types as a setting within WP_Query

Viewing 1 replies (of 1 total)

The topic ‘How do I get hour range using the API ?’ is closed to new replies.