Skip to content

Instantly share code, notes, and snippets.

@Boztown
Created January 2, 2014 22:46
Show Gist options
  • Save Boztown/8228583 to your computer and use it in GitHub Desktop.
Save Boztown/8228583 to your computer and use it in GitHub Desktop.
Popular posts (by comment count) in Wordpress with no plug-in
<?php $pop = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}posts WHERE post_type='post' AND post_status='publish' ORDER BY comment_count DESC LIMIT 10"); ?>
<?php foreach($pop as $post) : ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endforeach; ?>
<?php foreach($pop as $post) : ?>
<ul>
<li> <?php the_title(); ?> </li>
</ul>
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment