Created
March 23, 2012 07:43
-
-
Save hsquareweb/2168032 to your computer and use it in GitHub Desktop.
WP: Popular Posts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Popular Posts</h2> | |
<ul> | |
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5"); | |
foreach ($result as $post) { | |
setup_postdata($post); | |
$postid = $post->ID; | |
$title = $post->post_title; | |
$commentcount = $post->comment_count; | |
if ($commentcount != 0) { ?> | |
<li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>"> | |
<?php echo $title ?></a> {<?php echo $commentcount ?>}</li> | |
<?php } } ?> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment