WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a project where editors need to see the pending posts on the homepage to improve them before publish.

Maybe there is something to do with the loop in this way:

If editors logged:

if ( current_user_can('edit_post') ) {
    display the pending posts

The args to display publish and pending posts:

$args = array( 'post_type' => 'post', 'post_status' => 'publish, pending' );

The completed loop:

if ( current_user_can('edit_post') ) {
    $args = array( 'post_type' => 'post', 'post_status' => 'publish, pending' );
} else {
    $args = array( 'post_type' => 'post', 'post_status' => 'publish' );
$wp_query = new WP_Query($args); while ( have_posts() ) : the_post(); ?>

…the content here...

<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>

It work for me.

Do you think this is correct?

Maybe the code can be improved.

Thanks for the help.

share|improve this question
up vote 3 down vote accepted

I would filter pre_get_posts.

function allow_pending_posts_wpse_103938($qry) {
  if (!is_admin() && current_user_can('edit_posts')) {
    $qry->set('post_status', array('publish','pending'));

That should show pending posts to your editors for all of your queries on the front end. You can, of course, restrict is more if you'd like.

I'd add some code to mark the pending posts so your editors know at a glance what is pending.

share|improve this answer
Very nice. Well done. Thank a lot! – jeromeM Jun 23 '13 at 16:58
I reiterate, that will effect all queries on the front end. Be aware. – s_ha_dum Jun 23 '13 at 16:59
Yes, exactly what I need. Thank again. – jeromeM Jun 23 '13 at 19:30

Your Answer


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.