Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I currently have the following query:

$args = array(
              'post_type' => 'post',
              'orderby'   => 'title',
              'order'     => 'ASC',
              'posts_per_page' => 10,
            );

$my_query = new WP_Query($args);

while ($my_query->have_posts()) : $my_query->the_post(); ?>

This returns all the posts that are published. How can I alter it to show every post whether it's published, pending, or in draft?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You can add post_status to your query, the string 'any' will return all posts no matter the status, or you can use an array to just grab those you want.

$args = array(
              'post_type' => 'post',
              'orderby'   => 'title',
              'order'     => 'ASC',
              'post_status' => 'any',
              'posts_per_page' => 10,
            );

http://codex.wordpress.org/Class_Reference/WP_Query#Type_.26_Status_Parameters

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.