public
Created

List the 5 most popular posts tagged "basic".

  • Download Gist
functions.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?php
 
echo '<h4>Popular Basic Posts</h4>';
$args = array(
'posts_per_page' => 5,
'orderby' => 'meta_value_num',
'meta_key' => 'be_stats',
'order' => 'ASC',
'tag' => 'basic',
);
$loop = new WP_Query( $args );
if( $loop->have_posts() ):
echo '<ol>';
while( $loop->have_posts() ): $loop->the_post(); global $post;
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
endwhile;
echo '</ol>';
endif;
wp_reset_postdata();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.