Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created February 20, 2013 17:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save billerickson/4997202 to your computer and use it in GitHub Desktop.
Save billerickson/4997202 to your computer and use it in GitHub Desktop.
List the 5 most popular posts tagged "basic".
<?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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment