Title: get_posts posting wrong post categories
Last modified: August 21, 2016

---

# get_posts posting wrong post categories

 *  Resolved [icakeov](https://wordpress.org/support/users/itucakov/)
 * (@itucakov)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/get_posts-posting-wrong-post-categories/)
 * Hi I have seen some posts on this topic but haven’t found the solution.
 * I am passing only one category into the query (in this case 18):
 *     ```
       $args = array( 'offset' => 0,'numberposts' => 4, 'post_status'=>"publish",'lang' => 'en','post_type'=>"post",'orderby'=>"post_date",'order'=> 'DESC','category' => 18);
       $postslist = get_posts( $args );
       foreach ($postslist as $post) : setup_postdata($post);
       ```
   
 * But it is displaying other posts that don’t have category 18..
 * I’ve seen that wp_query works really well. Should I just switch to that?
    Or 
   is there a known solution to this issue with get_posts?
 * Thanks!

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/get_posts-posting-wrong-post-categories/#post-4503542)
 * try to use:
 * `'cat' => 18`
 * or
 * `'category__in' => array( 18 )`
 * [http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters)
 *  Thread Starter [icakeov](https://wordpress.org/support/users/itucakov/)
 * (@itucakov)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/get_posts-posting-wrong-post-categories/#post-4503549)
 * “category__in” seems to have worked!
    I used it as ”category__in’ => 18′ though(
   without the array). Should I do the array just to be on the safe side? Thanks
   alchymyth!

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

The topic ‘get_posts posting wrong post categories’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [icakeov](https://wordpress.org/support/users/itucakov/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/get_posts-posting-wrong-post-categories/#post-4503549)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
