How do I display views using the API ?
-
I would like to get top 5 daily posts from the past 24 hours and orderby views…displaying the daily count.
Tried to use ‘daily_count’ => true, but is not working, this is what i have:if ( function_exists( ‘get_tptn_pop_posts’ ) ) {
$settings = array(
‘daily’ => TRUE,
‘hour_range’ => 24,
‘limit’ => 5,
‘daily_count’ => true,
‘strict_limit’ => FALSE,
);
$topposts = get_tptn_pop_posts( $settings );
$topposts = wp_list_pluck( (array) $topposts, ‘postnumber’ );$args = array(
‘cat’ => $my_category_id,
‘post__in’ => $topposts,
‘posts_per_page’ => 5,
‘orderby’ => ‘post__in’,
‘order’ => ‘DESC’,
);$my_query = new WP_Query($args);
if ( $my_query->have_posts() ) :
while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
<!–content here–>
<?php endwhile; ?>
<?php wp_reset_query(); endif;
}
?>It is displaying 5 posts from the right category but cant get to display count and orderby views DESC. Any suggestions? Thanks in advance.
- The topic ‘How do I display views using the API ?’ is closed to new replies.