post_author_meta_box()WP 2.6.0

Displays form field with list of authors.

No Hooks.

Return

null. Nothing (null).

Usage

post_author_meta_box( $post );
$post(WP_Post) (required)
Current post object.

Notes

  • Global. Int. $user_ID

Changelog

Since 2.6.0 Introduced.

post_author_meta_box() code WP 6.6

<?php
function post_author_meta_box( $post ) {
	global $user_ID;

	$post_type_object = get_post_type_object( $post->post_type );
	?>
<label class="screen-reader-text" for="post_author_override">
	<?php
	/* translators: Hidden accessibility text. */
	_e( 'Author' );
	?>
</label>
	<?php
	wp_dropdown_users(
		array(
			'capability'       => array( $post_type_object->cap->edit_posts ),
			'name'             => 'post_author_override',
			'selected'         => empty( $post->ID ) ? $user_ID : $post->post_author,
			'include_selected' => true,
			'show'             => 'display_name_with_login',
		)
	);
}