remove_meta_box

Removes a meta box from one or more screens.

Description

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

Parameters (3)

0. $id (string)
Meta box ID (used in the id attribute for the meta box).
1. $screen (string|array|WP_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.
2. $context (string)
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.

Usage

  1. if ( !function_exists( 'remove_meta_box' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/template.php'; 
  3.  
  4. // Meta box ID (used in the 'id' attribute for the meta box). 
  5. $id = ''; 
  6. $screen = null; 
  7. $context = ''; 
  8.  
  9. // NOTICE! Understand what this does before running. 
  10. $result = remove_meta_box($id, $screen, $context); 
  11.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/template.php  
  1. function remove_meta_box( $id, $screen, $context ) { 
  2. global $wp_meta_boxes; 
  3.  
  4. if ( empty( $screen ) ) { 
  5. $screen = get_current_screen(); 
  6. } elseif ( is_string( $screen ) ) { 
  7. $screen = convert_to_screen( $screen ); 
  8. } elseif ( is_array( $screen ) ) { 
  9. foreach ( $screen as $single_screen ) { 
  10. remove_meta_box( $id, $single_screen, $context ); 
  11.  
  12. if ( ! isset( $screen->id ) ) { 
  13. return; 
  14.  
  15. $page = $screen->id; 
  16.  
  17. if ( !isset($wp_meta_boxes) ) 
  18. $wp_meta_boxes = array(); 
  19. if ( !isset($wp_meta_boxes[$page]) ) 
  20. $wp_meta_boxes[$page] = array(); 
  21. if ( !isset($wp_meta_boxes[$page][$context]) ) 
  22. $wp_meta_boxes[$page][$context] = array(); 
  23.  
  24. foreach ( array('high', 'core', 'default', 'low') as $priority ) 
  25. $wp_meta_boxes[$page][$context][$priority][$id] = false;