On this page
post_author_meta_box( WP_Post $post )
Displays form field with list of authors.
Parameters
$postWP_Post Required-
Current post object.
Source
File: wp-admin/includes/meta-boxes.php. View all references
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 _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',
)
);
}
Related
Uses
| Uses | Description |
|---|---|
| wp_dropdown_users() wp-includes/user.php | Creates dropdown HTML content of users. |
| _e() wp-includes/l10n.php | Displays translated text. |
| get_post_type_object() wp-includes/post.php | Retrieves a post type object by name. |
Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/post_author_meta_box