Step-by-Step Guide: How to Remove Meta Boxes in WordPress

Home » Snippets » Step-by-Step Guide: How to Remove Meta Boxes in WordPress
0

Created with:

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

Are you looking to declutter your WordPress dashboard by removing unnecessary or unused meta boxes? A clean, streamlined dashboard can simplify your user experience and increase productivity. In this article, we will guide you through the steps on how to remove meta boxes, enabling you to personalize your WordPress dashboard according to your preferences.

					function wpturbo_remove_meta_boxes() {
    remove_meta_box('authordiv', 'post', 'normal'); // Author meta box
    remove_meta_box('commentsdiv', 'post', 'normal'); // Comments meta box
    remove_meta_box('revisionsdiv', 'post', 'normal'); // Revisions meta box
}
add_action('admin_menu', 'wpturbo_remove_meta_boxes');
				

The given code snippet is centered around a WordPress function called wpturbo_remove_meta_boxes(). This function’s job is to remove specified meta boxes from the "post" editing screen in the WordPress admin dashboard.

remove_meta_box() is a built-in WordPress function used to remove meta boxes from the post editing screen. It takes three parameters: the ID of the meta box, the screen where the meta box is displayed, and the context where on the screen it’s displayed.

Our function calls remove_meta_box() three times, each time to target a different meta box:

  1. remove_meta_box('authordiv', 'post', 'normal'); – This line of code removes the Author meta box from the post editing screen. ‘authordiv’ is the ID of the Author meta box, ‘post’ tells WordPress that we want to remove this meta box from the post screen, and ‘normal’ is the section of the post edit screen where the meta box is located.

  2. remove_meta_box('commentsdiv', 'post', 'normal'); – Similar to the previous line, this code removes the Comments meta box from the post editing screen.

  3. remove_meta_box('revisionsdiv', 'post', 'normal'); – This line of code removes the Revisions meta box from the post editing screen.

Lastly, we use add_action() to trigger our function. add_action() is a critical part of WordPress’s event-driven (hooks) system, and it is used to tell WordPress when to execute our function. In our case, we want WordPress to call wpturbo_remove_meta_boxes() during the ‘admin_menu’ hook which fires before the admin menu is rendered, thereby ensuring that the meta boxes are removed before the post editing screen is drawn.

Register an account to save your snippets or go Pro to get more features.