Removes a meta box or any other element from a particular post edit screen of a given post type. It can be also used to remove a widget from the dashboard screen.

remove_meta_box() 描述


<?php remove_meta_box$id$page$context ); ?>

remove_meta_box() 用法



(string) (必填) Value of the id attribute of the HTML element to remove. Some of the available id values are given below:

  • 'authordiv' – Author metabox
  • 'categorydiv' – Categories metabox.
  • 'commentstatusdiv' – Comments status metabox (discussion)
  • 'commentsdiv' – Comments metabox
  • 'formatdiv' – Formats metabox
  • 'pageparentdiv' – Attributes metabox
  • 'postcustom' – Custom fields metabox
  • 'postexcerpt' – Excerpt metabox
  • 'postimagediv' – Featured image metabox
  • 'revisionsdiv' – Revisions metabox
  • 'slugdiv' – Slug metabox
  • 'submitdiv' – Date, status, and update/save metabox
  • 'tagsdiv-post_tag' – Tags metabox
  • '{$tax-name}div' - Hierarchical custom taxonomies metabox
  • 'trackbacksdiv' – Trackbacks metabox
  • ...

默认值: None


(string) (必填) Type of the screen to remove the meta box from, such as:

  • 'post'
  • 'page'
  • 'attachment'
  • 'link'
  • 'dashboard'
  • or any registered custom post type, e.g. 'my-product'

默认值: None


(string) (必填) 'normal', 'advanced', or 'side'.

默认值: None

remove_meta_box() 参数



remove_meta_box() 返回值


This example removes certain meta boxes from the post edit screens of both the Post and Link post types for non-administrators.

Here is an example that removes the Custom Fields box from the Post edit screen.

Here is another example that removes the Excerpt meta box from the Page edit screen,

This example removes the Comments, Author and Comments Status meta boxes from the Page edit screen,

If you want to remove a custom taxonomy box from a custom post type edit screen, you can use this:

Even the Publish box can be removed if desired:

To remove all the widgets from the dashboard screen, use:

To remove meta boxes created by plugins, 'admin_menu' is fired too early, use 'do_meta_boxes' instead.
This is helpful for instances when you want to limit meta boxes by user capability:

remove_meta_box() 示例



Because you can't remove a meta box until it's been added, it's important to make sure your call to remove_meta_box() happens in the right sequence. Just adding a call to remove_meta_box() bare in your functions.php will probably not do the trick.

The add_meta_boxes 动作 hook is probably a good candidate, since most of your meta boxes are generated on the edit post form page. This hook is called in the wp-admin/edit-form-advanced.php file after all the meta boxes have been successfully added to the page. This affects all meta boxes (conceivably, other than those that are custom generated by a theme or plugin) that appear on post edit pages (including custom post types edit pages) of the administration back-end.

remove_meta_box() 注意


添加于 版本: 2.6

remove_meta_box() 历史


remove_meta_box() 函数的代码位于 wp-admin/includes/template.php

remove_meta_box() 源文件