• Hi everyone,

    I am trying to display the most popular posts on Blog page, but nothing works. I’ve tried several codes and can’t manage.

    For example:

    <?php
    								$args=array(
    									'meta_key' => 'post_views_count',
    									'orderby' => 'meta_value_num',
    									'posts_per_page' => 2
    						      	);
    
    				      			$my_query = null;
    								$my_query = new WP_Query($args);
    								if( $my_query->have_posts() ) {
    									while ($my_query->have_posts()) : $my_query->the_post(); ?>
    										<div class="col-sm-12">
    											<?php get_template_part('template/blog-summary'); ?>
    										</div>
    										<?php
    									the_content();
    									endwhile;
    								}
    							?>

    or https://digwp.com/2016/03/diy-popular-posts/.

    But it does not display a thing, why is that?

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Popular posts’ is closed to new replies.