[resolved] get_posts returns an empty array (4 posts)

  1. moikirsch
    Posted 3 years ago #

    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 );

    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?


  2. Michael
    Forum Moderator
    Posted 3 years ago #

    where is that code located?

    in the main loop?
    is it in a function?

  3. moikirsch
    Posted 3 years ago #

    Inside the main loop.

    A sample of the values in $argumentos:

        [posts_per_page] => -1
        [orderby] => menu_order
        [order] => ASC
        [post_type] => attachment
        [post_parent] => 20
        [post_status] =>
        [exclude] => 39
        [post_mime_type] => image
  4. moikirsch
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic