Swatist
2/21/2017 - 1:53 PM

how to display popular posts

how to display popular posts

http://www.wpbeginner.com/wp-tutorials/how-to-track-popular-posts-by-views-in-wordpress-without-a-plugin/
 <?php global $post;
				   $args = array( 'numberposts' => 5);
				   $myposts = get_posts( $args );
				   foreach( $myposts as $post ) :  setup_postdata($post); ?>            
			<div class="wrap-postPopular">
			<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'popular-post');?>
			  <h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
			  <div class="postImg"><img src="<?php echo $image[0];?>">
				<div>
				  <div class="cal"> <span> <i class="fa fa-calendar" aria-hidden="true"></i> <em><?php $post_date = get_the_date( 'j F  Y' ); echo $post_date; ?></em> </span> </div>
				  <p class="viewsPost"><?php setPostViews(get_the_ID()); echo getPostViews(get_the_ID());?></p>
				</div>
			  </div>
			</div>
			<?php endforeach; ?>