Skip to content

Instantly share code, notes, and snippets.

@webhasan
Created January 29, 2014 09:47
Show Gist options
  • Save webhasan/8684722 to your computer and use it in GitHub Desktop.
Save webhasan/8684722 to your computer and use it in GitHub Desktop.
wp: post query by comment_count
<?php
$pop = $wpdb->get_results("SELECT id,post_title,guid FROM {$wpdb->prefix}posts WHERE post_type='post' ORDER BY comment_count DESC LIMIT 10");
foreach($pop as $post) : ?>
<li><a href="<?php echo $post->guid; ?>"><?php echo get_the_post_thumbnail($post->id); ?></li>
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment