Title: loop posts by most &quot;viewed&quot;
Last modified: August 30, 2016

---

# loop posts by most "viewed"

 *  [pahroblem](https://wordpress.org/support/users/pahroblem/)
 * (@pahroblem)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/loop-posts-by-most-viewed/)
 * Hey mate loving the plugin
 * How would i sort my posts loop by the hit number?
 * heres my loop
 *     ```
       <?php
       $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
       $args = array(
       'post_type' => array( 'post' ),
       'posts_per_page' => 12,
       'category_name' => strategy,
       'paged' => $paged
       );
       $the_query = new WP_Query( $args );
       ?>
   
       <?php if ( $the_query->have_posts('paged') ) : ?>
       <?php while ( $the_query->have_posts('paged') ) : $the_query->the_post('paged'); ?>
   
       				<?php get_template_part( 'content' ); ?>	
   
       		<?php endwhile; ?>
   
       <?php wp_reset_postdata(); ?>
       <?php else : ?>
   
       <?php endif; ?>
       ```
   
 * [https://wordpress.org/plugins/post-hit-counter/](https://wordpress.org/plugins/post-hit-counter/)

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

 *  Thread Starter [pahroblem](https://wordpress.org/support/users/pahroblem/)
 * (@pahroblem)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/loop-posts-by-most-viewed/#post-6344105)
 * Guess ill just look for an alternative.
 *  [graffo](https://wordpress.org/support/users/graffo/)
 * (@graffo)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/loop-posts-by-most-viewed/#post-6344205)
 * This plugin saves the hist info on a meta key called ‘_posts_views’, then you
   can order by a meta key.
 *  [truonght](https://wordpress.org/support/users/truonght/)
 * (@truonght)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/loop-posts-by-most-viewed/#post-6344206)
 * you can add this to $args array:
 *     ```
       'meta_key' => '_posts_views',
       'orderby' => 'meta_value_num',
       'order' => 'DESC',
       ```
   

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

The topic ‘loop posts by most "viewed"’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/post-hit-counter_008c8c.svg)
 * [Post Hit Counter](https://wordpress.org/plugins/post-hit-counter/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-hit-counter/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-hit-counter/)
 * [Active Topics](https://wordpress.org/support/plugin/post-hit-counter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-hit-counter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-hit-counter/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [truonght](https://wordpress.org/support/users/truonght/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/loop-posts-by-most-viewed/#post-6344206)
 * Status: not resolved