Title: get_posts fails to return drafts and published posts
Last modified: August 20, 2016

---

# get_posts fails to return drafts and published posts

 *  [GrahamW](https://wordpress.org/support/users/grahamw/)
 * (@grahamw)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/get_posts-post_status-arraydraft-publish/)
 * Hi,
    I can’t get the get_posts function to return both drafts and published posts.
   This is my code:
 *     ```
       $args = array(
       	'numberposts'	=> NULL,
           'offset'		=> 0,
           'orderby'		=> 'title',
           'order'			=> 'ASC',
           'post_type'		=> 'post',
       	'post_status'	=> array('drafts', 'publish')
       	);
       $Post_Array = get_posts($args);
       ```
   
 * If I run the function twice and combine the resulting arrays it works, but then
   the orderby is wrong because it just adds the second array to the end of the 
   first array. Here is the code:
 *     ```
       $args = array(
       $args = array(
       	'numberposts'	=> NULL,
           'offset'		=> 0,
           'orderby'		=> 'title',
           'order'			=> 'ASC',
           'post_type'		=> 'post',
       	'post_status'	=> 'draft'
       	);
       $Post_Array1 = get_posts($args);
   
       $args = array(
       	'numberposts'	=> NULL,
           'offset'		=> 0,
           'orderby'		=> 'title',
           'order'			=> 'ASC',
           'post_type'		=> 'post',
       	'post_status'	=> 'publish'
       	);
       $Post_Array2 = get_posts($args);
   
       $Post_Array = array_merge((array)$Post_Array1, (array)$Post_Array2);
       ```
   

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/get_posts-post_status-arraydraft-publish/#post-2292098)
 * typing error?
 *     ```
       'post_status'	=> array('drafts', 'publish')
       ```
   
 * make sure it says `'draft'` in your real code…
 *  Thread Starter [GrahamW](https://wordpress.org/support/users/grahamw/)
 * (@grahamw)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/get_posts-post_status-arraydraft-publish/#post-2292100)
 * Thank you!!!
 * I must have mistyped that at least 3 times. lol
    I think I need a break lol
 * Regards,
    Graham

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

The topic ‘get_posts fails to return drafts and published posts’ is closed to new
replies.

## Tags

 * [get_posts](https://wordpress.org/support/topic-tag/get_posts/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [GrahamW](https://wordpress.org/support/users/grahamw/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/get_posts-post_status-arraydraft-publish/#post-2292100)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
