Title: statistics in loop
Last modified: August 24, 2016

---

# statistics in loop

 *  Resolved [jaavid](https://wordpress.org/support/users/jaavid/)
 * (@jaavid)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/statistics-in-loop/)
 * is there any way to use hits in wp_query to sort by hits?
 * [https://wordpress.org/plugins/wp-statistics/](https://wordpress.org/plugins/wp-statistics/)

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

 *  Plugin Contributor [Greg Ross](https://wordpress.org/support/users/gregross/)
 * (@gregross)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/statistics-in-loop/#post-5958804)
 * No, we don’t support wp_query.
 *  Thread Starter [jaavid](https://wordpress.org/support/users/jaavid/)
 * (@jaavid)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/statistics-in-loop/#post-5959073)
 * 🙂
 *     ```
       global $wpdb;
       $results = $wpdb -> get_results('SELECT wp_statistics_pages.id
       FROM wp_statistics_pages
       JOIN wp_posts
       ON wp_posts.ID = wp_statistics_pages.id
       WHERE wp_posts.post_type = 'publication'
       GROUP BY id
       ORDER BY count
       DESC
       LIMIT 10', ARRAY_A );
   
       $args = array(
       'post_type'  => 'publication',
       'post__in'  => $results,
       'orderby'   => 'post__in'
       );
       $query = new WP_Query( $args );
       ```
   

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

The topic ‘statistics in loop’ is closed to new replies.

 * ![](https://ps.w.org/wp-statistics/assets/icon.svg?rev=3081064)
 * [WP Statistics – Simple, privacy-friendly Google Analytics alternative](https://wordpress.org/plugins/wp-statistics/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-statistics/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-statistics/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-statistics/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-statistics/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-statistics/reviews/)

## Tags

 * [hits](https://wordpress.org/support/topic-tag/hits/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)

 * 2 replies
 * 2 participants
 * Last reply from: [jaavid](https://wordpress.org/support/users/jaavid/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/statistics-in-loop/#post-5959073)
 * Status: resolved