Title: Multiple category recent posts
Last modified: August 18, 2016

---

# Multiple category recent posts

 *  Resolved [wagawaga](https://wordpress.org/support/users/wagawaga/)
 * (@wagawaga)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/multiple-category-recent-posts/)
 * Hi,
 * I got a few categories say 1-5. I would like to display recent posts from category
   1-3, excluding 4-5. How to do that?
 * The display will mix the posts from category 1-3

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Drew](https://wordpress.org/support/users/drewrockshard/)
 * (@drewrockshard)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/multiple-category-recent-posts/#post-548512)
 * I apologize. You said, RECENT posts didn’t you. I believe there is a plugin out
   there called recent posts plugin. That can be found [here](http://mtdewvirus.com/code/wordpress-plugins/).
   I am not sure if you can exclude certain categories though. I would start searching
   the forums on this though, I’m sure this has been discussed, and you should have
   searched before posting. I know I have seen this before.
 * Regards,
    Drew
 *  Thread Starter [wagawaga](https://wordpress.org/support/users/wagawaga/)
 * (@wagawaga)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/multiple-category-recent-posts/#post-548674)
 * OK Thanks.
 *  Thread Starter [wagawaga](https://wordpress.org/support/users/wagawaga/)
 * (@wagawaga)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/multiple-category-recent-posts/#post-548768)
 * still i could not find what am i looking for. can anybody help me to point which
   post does suit what i need?
 * yes i want to display recent posts but for certain categories only, not all.
 *  [Chris_K](https://wordpress.org/support/users/handysolo/)
 * (@handysolo)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/multiple-category-recent-posts/#post-548769)
 * where are we displaying these posts? Main index? Sidebar?
 *  Thread Starter [wagawaga](https://wordpress.org/support/users/wagawaga/)
 * (@wagawaga)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/multiple-category-recent-posts/#post-548774)
 * sidebar…
 * i found post like this one, but i’m not sure;
    I use the following code to generate
   a list of the titles of the 10 most recent post in my sidebar and exclude 1 category(
   with id=18 in this example):
    -  <?php $temp_query = $wp_query; query_posts(‘showposts=10&cat=-18’); ?>
       <?
      php while (have_posts()) { the_post(); ?>
    - 
    - <?php } $wp_query = $temp_query; ?>
 * i found this error;
 *  WordPress database error: [Not unique table/alias: ‘wp_post2cat’]
    SELECT SQL_CALC_FOUND_ROWS
   wp_posts.*, wp_sticky.sticky_status FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.
   ID = wp_post2cat.post_id) LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.
   post_id) LEFT JOIN wp_sticky ON wp_sticky.sticky_post_id = wp_posts.ID WHERE 
   1=1 AND wp_posts.ID NOT IN (3) AND (post_type = ‘post’ AND (post_status = ‘publish’))
   AND category_id NOT IN (1,2) GROUP BY wp_posts.ID ORDER BY (wp_sticky.sticky_status
   = 2 AND wp_sticky.sticky_status IS NOT NULL) DESC, DATE_FORMAT(wp_posts.post_date,’%
   Y-%m-%d’) DESC, (wp_sticky.sticky_status = 1 AND wp_sticky.sticky_status IS NULL)
   DESC, DATE_FORMAT(wp_posts.post_date,’%T’) DESC LIMIT 0, 10
 * how to exclude a few categories from recent post in the sidebar?
 *  Thread Starter [wagawaga](https://wordpress.org/support/users/wagawaga/)
 * (@wagawaga)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/multiple-category-recent-posts/#post-548775)
 * i found the solution, using coffee to code plug ins. thanks

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Multiple category recent posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [wagawaga](https://wordpress.org/support/users/wagawaga/)
 * Last activity: [19 years, 2 months ago](https://wordpress.org/support/topic/multiple-category-recent-posts/#post-548775)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
