crazyyy
4/28/2014 - 11:41 AM

WordPress: sort by post view

WordPress: sort by post view

http://subharanjan.com/how-to-display-wordpress-posts-sorted-by-post-view-count-solved-without-a-plugin/
<?php
  $args = array(
    'orderby'      => 'meta_value',
    'meta_key'     => 'post_views_count',
    'order'        => 'DESC',
    'post_status'  => 'publish'
  ); 
  $ranking = 0;
?>
<?php query_posts($args); ?>
<?php if ( have_posts() ) : ?>
  <?php while ( have_posts()) : the_post();  $ranking++; ?>

  <!-- HTML --> 
  
<?php endwhile; endif;  wp_reset_query(); ?>