How To Sort Posts by "post view"
-
This is my base code of archive-albums.php
?php while ( have_posts() ) : the_post(); ?> <div class="section group albumlist"> <div class="col x6 "> <a href="<?php echo get_permalink(); ?>"title="<?php the_title(); ?>"><?php the_title(); ?></a></div> <div class="col x3 "><?php $alb_categories = get_the_term_list( $post->ID, 'genre', '', ', ', '' ); echo $alb_categories; ?></div> <div class="col x2 "><?php echo get_post_meta($post->ID, 'wpcf-total-songs', true); ?> songs</div> <div class="col x1 "><?php echo get_post_meta($post->ID, 'wpcf-release', true); ?> </div> </div> <?php endwhile; ?> <?php wp_pagenavi(); ?>
I can use
get_post_total_views()
within the loop to get a post’s total view, eg:100, 500 ,1500 etc (a plugin), Now I want to know, Can I sort my albums by post view? If yes where to modify?
- The topic ‘How To Sort Posts by "post view"’ is closed to new replies.