Title: How do I display views using the API ?
Last modified: August 31, 2016

---

# How do I display views using the API ?

 *  [chouch7](https://wordpress.org/support/users/chouch7/)
 * (@chouch7)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/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.
 * [https://wordpress.org/plugins/top-10/](https://wordpress.org/plugins/top-10/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/how-do-i-display-views-using-the-api/#post-7423434)
 * Does it work if you remove the `'order' => 'DESC',`
 * By default the API pulls the top posts by descending order only
 *  Thread Starter [chouch7](https://wordpress.org/support/users/chouch7/)
 * (@chouch7)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/how-do-i-display-views-using-the-api/#post-7423499)
 * I cant see the daily_count, is it suppose to show next to the post title or how
   does it works?
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/how-do-i-display-views-using-the-api/#post-7423557)
 * Can I see the page where you’re displaying this? And also point me to what you’re
   trying to display?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How do I display views using the API ?’ is closed to new replies.

 * ![](https://ps.w.org/top-10/assets/icon-256x256.png?rev=2986432)
 * [WebberZone Top 10 — Popular Posts](https://wordpress.org/plugins/top-10/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/top-10/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/top-10/)
 * [Active Topics](https://wordpress.org/support/plugin/top-10/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/top-10/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/top-10/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [count](https://wordpress.org/support/topic-tag/count/)
 * [order](https://wordpress.org/support/topic-tag/order/)
 * [orderby](https://wordpress.org/support/topic-tag/orderby/)

 * 3 replies
 * 2 participants
 * Last reply from: [Ajay](https://wordpress.org/support/users/ajay/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/how-do-i-display-views-using-the-api/#post-7423557)
 * Status: not resolved