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.

On a large multisite install with 200 authors I need the author on new posts to default to none.

I unset the post_author div and moved it to the publish box (where it should be anyway) and wrote a new post_author_meta_box function since there is no way to change the wp_dropdown_users $args. <--track ticket.

It works and sets the author to none but when a post is edited it goes back to none instead of the previously saved author.

//Replacement for post_author_meta_box 

function better_author_meta_box($post) { ?>  
   <label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label> <?php

    if ( empty($post->ID) ) : $selected = false; else : $selected = $post->post_author; endif;
    wp_dropdown_users( array(
            'who' => 'authors',
            'name' => 'post_author_override',
            'selected' => $selected,
//also tried: 'selected' => empty($post->ID) ? false : $post->post_author, 
            'include_selected' => true,
            'show_option_none' => 'NONE'
      ) );
  }

//Moves post_author_div to the publish box
add_action( 'post_submitbox_misc_actions', 'move_author_meta' );
function move_author_meta() {
global $post_ID;
$post = get_post( $post_ID );
echo '<div id="author" class="misc-pub-section" style="border-top-style:solid; border-top-width:1px; border-top-color:#EEEEEE; border-bottom-width:0px;">Author: ';
better_author_meta_box( $post );
echo '</div>';
}
share|improve this question

1 Answer 1

up vote 0 down vote accepted

I figured out a solution so I'm leaving the question up as it might be helpful to someone else.

if ( 'auto-draft' == $post->post_status ) : 
   $selected = false; 
  else : 
   $selected = $post->post_author; 
endif;
share|improve this answer

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.