WordPress.org

Ready to get started?Download WordPress

Forums

query_posts and trash items - strange (3 posts)

  1. Richard Vencu
    Member
    Posted 3 years ago #

    Hi, I noticed that those two queries produce different results, meaning that the one with the array also returns unwanted items from trash. Of course there is no need for array but it returns items from trash even if I specify the array as array('publish','draft'). I am not sure if this is only custom taxonomy related behaviour or a general one. I am using that in the author.php, hence the $curauth->ID and the rest.

    first one

    $dentfix_query = array (
    'post_type'=>array('statusdentar','tratamente'),
    'author'=>$curauth->ID,
    'post_status'=>'publish',
    'dinti'=>'1'.$e
    );
    query_posts( $dentfix_query );

    and second one

    $dentfix_query = array (
    'post_type'=>array('statusdentar','tratamente'),
    'author'=>$curauth->ID,
    'post_status'=>array('publish'),
    'dinti'=>'1'.$e
    );
    query_posts( $dentfix_query );
  2. pyrosix
    Member
    Posted 3 years ago #

    Hello, I have the exact same problem...
    If you or anyone else has found a solution please reply.

    Thanks.

  3. goto10
    Member
    Posted 3 years ago #

    Hey guys, I had the same issue. Unfortunately for me, I needed to query multiple stati.

    Long story short, you can achieve this by passing a comma separated string for the value of post_status.

    ...
    'post_status'    => 'publish,pending',
    ...

    I submitted a ticket to trac, since the codex does state that an array is a valid way to pass the post_status argument.

Topic Closed

This topic has been closed to new replies.

About this Topic