remove_meta_box()

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

remove_meta_box(string $id,string|array|WP_Screen $screen,string $context)

参数(Parameters)

参数类型必填说明
$id(string)必需元框ID(用于元框的“ID”属性)。
$screen(string | array | WP_Screen)必需显示元框的一个或多个屏幕(例如post类型、“link”或“comment”)。接受单个屏幕ID、WP_屏幕对象或屏幕ID数组。
$context(string)必需框设置为显示的屏幕中的上下文。上下文因屏幕而异。后期编辑屏幕上下文包括“normal”、“side”和“advanced”。注释屏幕上下文包括“normal”和“side”。菜单元框(accordion部分)都使用“side”上下文。

返回(Return)

无返回值


源码(Source)

/**
 * Remove a meta box from an edit form.
 *
 * @since 2.6.0
 *
 * @global array $wp_meta_boxes
 *
 * @param string        $id      String for use in the 'id' attribute of tags.
 * @param string|object $screen  The screen on which to show the box (post, page, link).
 * @param string        $context The context within the page where the boxes should show ('normal', 'advanced').
 */
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 );
	$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;
}
更新版本源码位置使用被使用
4.4.0wp-admin/includes/template.php:13771 function3

笔记(Notes)

这将只删除摘录,如果你不使用古腾堡编辑器。
下面是一个从后期编辑屏幕中删除“自定义字段”框的示例。
下面是另一个从页面编辑屏幕中删除摘录元框的示例,

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索