Most Popular in one category
-
Is there a way that I can get only the most popular posts in specified category? the code I am using currently in template is below:
<h2>Most Popular</h2> <ul class="mostpop"> <?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 10"); 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></li> <?php } } ?> </ul>
thanks for your help!!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Most Popular in one category’ is closed to new replies.