Title: get_posts returns an empty array
Last modified: August 20, 2016

---

# get_posts returns an empty array

 *  Resolved [moikirsch](https://wordpress.org/support/users/moikirsch/)
 * (@moikirsch)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/get_posts-returns-an-empty-array/)
 * I have the following code (sorry for the spanish):
 *     ```
       // Argumentos para traernos el thumbnail
       $argumentos = array(
       	'posts_per_page' => -1,
       	'orderby' => 'menu_order',
       	'order' => 'ASC',
       	'post_type' => 'attachment',
       	'post_parent' => $post->ID,
       	'post_status' => null,
       	'exclude' => $logo,
       	'post_mime_type' => 'image'
       	);
   
       $imagenes = get_posts( $argumentos );
   
       print_r($argumentos);
       print_r($imagenes);
       ```
   
 * The array of arguments seems fine and this is actually a copy/paste from an old
   code that I was using before but for some reason get_posts is returning an empty
   array.
 * I’m starting to think that the problem might be related to the new media managemente
   on version 3.5.
 * Does anyone know how to accomplish something similar or does anyone can catch
   the problem?
 * Thanks

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/get_posts-returns-an-empty-array/#post-3477694)
 * where is that code located?
 * in the main loop?
    is it in a function?
 *  Thread Starter [moikirsch](https://wordpress.org/support/users/moikirsch/)
 * (@moikirsch)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/get_posts-returns-an-empty-array/#post-3477699)
 * Inside the main loop.
 * A sample of the values in $argumentos:
 *     ```
       Array
       (
           [posts_per_page] => -1
           [orderby] => menu_order
           [order] => ASC
           [post_type] => attachment
           [post_parent] => 20
           [post_status] =>
           [exclude] => 39
           [post_mime_type] => image
       )
       ```
   
 *  Thread Starter [moikirsch](https://wordpress.org/support/users/moikirsch/)
 * (@moikirsch)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/get_posts-returns-an-empty-array/#post-3477724)
 * Fixed! The problema was NOT with this piece of code… there was another filter
   adding some variables to WP_Query and because of that there was no results.
 * After modifying (removing) those filters everything seems to be fixed.

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

The topic ‘get_posts returns an empty array’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [moikirsch](https://wordpress.org/support/users/moikirsch/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/get_posts-returns-an-empty-array/#post-3477724)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
