Title: category wise popular posts
Last modified: August 20, 2016

---

# category wise popular posts

 *  [federrer](https://wordpress.org/support/users/federrer/)
 * (@federrer)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/category-wise-popular-posts/)
 * Hi,
 * I am looking for a code/plugin to show popular posts for that particular category.
   
   eg : blogs.mysite.com/announcement/ sidebar should show most commented posts 
   in announcements alone. and blogs.mysite.com/general/ sidebar should show most
   commented post for general category alone.
 * Now I am using this code to show.
 *     ```
       <li><h3>Popular Posts</h3>
       <ul class="bullets">
       <?php
       $popular_posts = $wpdb->get_results("SELECT id,post_title,comment_count FROM {$wpdb->prefix}posts where guid like '%crm%' ORDER BY comment_count DESC LIMIT 0,10");
       foreach($popular_posts as $post) {
       	print "<li><a href='". get_permalink($post->id) ."'>".$post->post_title."</a>(<a href='". get_permalink($post->id) ."'>".$post->comment_count."</a>)</li>\n";
       }
       ?>
       </ul>
       </li>
       ```
   
 * but it takes all the posts that contains “crm” in their GUID link.
 * I just want to know how to add category ID in the qry I used above ?
    I tried
   to search for it. but nothing meets my requerment.

The topic ‘category wise popular posts’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [federrer](https://wordpress.org/support/users/federrer/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/category-wise-popular-posts/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
