post_author_meta_box

函式
post_author_meta_box ( $post )
引數
  • (WP_Post) $post Current post object.
    Required:
定義位置
相關方法
post_custom_meta_boxpost_categories_meta_boxpost_submit_meta_boxpost_format_meta_boxpost_slug_meta_box
引入
2.6.0
棄用
-

post_author_meta_box: 該函式用於在文章編輯介面顯示作者元框,顯示文章作者的姓名和聯絡資訊。

顯示帶有作者列表的表格欄位。

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',
		)
	);
}

常見問題

FAQs
檢視更多 >