How do I get hour range using the API ?
-
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();
The topic ‘How do I get hour range using the API ?’ is closed to new replies.