remove_meta_box

函数
remove_meta_box ( $id, $screen, $context )
参数
  • (string) $id Meta box ID (used in the 'id' attribute for the meta box).
    Required:
  • (string|array|WP_Screen) $screen The screen or screens on which the meta box is shown (such as a post type, 'link', or 'comment'). Accepts a single screen ID, WP_Screen object, or array of screen IDs.
    Required:
  • (string) $context The context within the screen where the box is set to display. Contexts vary from screen to screen. Post edit screen contexts include 'normal', 'side', and 'advanced'. Comments screen contexts include 'normal' and 'side'. Menus meta boxes (accordion sections) all use the 'side' context.
    Required:
定义位置
相关方法
remove_theme_moddo_meta_boxesremove_theme_modsadd_meta_boxremove_menu_page
引入
2.6.0
弃用
-

remove_meta_box: 这个函数用来从WordPress的文章或页面编辑界面中删除一个元框。元框是用来给文章或页面编辑界面添加额外功能的: 这个函数需要三个参数:元框的ID,显示元框的屏幕,以及元框的上下文。

从一个或多个屏幕上删除一个元框。

function remove_meta_box( $id, $screen, $context ) {
	global $wp_meta_boxes;

	if ( empty( $screen ) ) {
		$screen = get_current_screen();
	} elseif ( is_string( $screen ) ) {
		$screen = convert_to_screen( $screen );
	} elseif ( is_array( $screen ) ) {
		foreach ( $screen as $single_screen ) {
			remove_meta_box( $id, $single_screen, $context );
		}
	}

	if ( ! isset( $screen->id ) ) {
		return;
	}

	$page = $screen->id;

	if ( ! isset( $wp_meta_boxes ) ) {
		$wp_meta_boxes = array();
	}
	if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
		$wp_meta_boxes[ $page ] = array();
	}
	if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
		$wp_meta_boxes[ $page ][ $context ] = array();
	}

	foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
		$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false;
	}
}

常见问题

FAQs
查看更多 >