Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <li id="meta" class="widget-container">
- <h3 class="widget-title"><?php _e( 'Popular Posts', 'twentyten' ); ?></h3>
- <?php
- $pop_posts = 5;
- $popularposts = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title, COUNT($wpdb->comments.comment_post_ID) AS 'stammy' FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish' AND comment_status = 'open' GROUP BY $wpdb->comments.comment_post_ID ORDER BY stammy DESC LIMIT ".$pop_posts;
- $posts = $wpdb->get_results($popularposts);
- if($posts){
- foreach($posts as $post){
- $post_title = stripslashes($post->post_title);
- $guid = get_permalink($post->ID);
- $thumb = get_post_meta($post->ID,'_thumbnail_id',false);
- $thumb = wp_get_attachment_image_src($thumb[0], 'post-thumbnail', false);
- $thumb = $thumb[0];
- ?>
- <div class="twentyten-popular-post">
- <?php if ($thumb) { ?>
- <img src="<?php echo $thumb; ?>" width=40 height=40 />
- <?php } ?>
- <a href="<?php echo $guid; ?>" title="<?php echo $post_title; ?>"><?php echo $post_title; ?></a>
- <div class="clear"></div>
- </div>
- <?php }
- }
- ?>
- </li>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement