How to Hide a Metabox in WordPress (post-new.php)

WP Customization

Working within the WordPress editor should be a clean and efficient experience. However, over time, the “Add New Post” screen can become cluttered with boxes and panels you rarely use. These are called metaboxes, and they can be added by your theme or various plugins. A crowded editor can slow you down and make content creation feel like a chore. Fortunately, you have the power to customize this space.

This guide will show you how to hide a metabox in the post-new.php file, which controls the WordPress post editor screen. We’ll explore what metaboxes are, why you might want to hide them, and provide clear, step-by-step methods to declutter your workspace for a more focused writing environment.

What Are WordPress Metaboxes?

Metaboxes are the draggable boxes you see on the post and page editor screens in your WordPress dashboard. By default, WordPress includes metaboxes for things like Categories, Tags, Featured Image, and the Excerpt.

Plugins and themes add their own metaboxes to provide extra functionality. For example:

  • An SEO plugin adds a metabox for optimizing your content.
  • A social sharing plugin might add one for custom social media messages.
  • A page builder could add a metabox to launch its interface.

While useful, not every user needs every metabox. A cluttered screen can be distracting and overwhelming, especially for clients or team members who only need access to basic editing features.

Why Hide a Metabox in WordPress?

There are several good reasons to hide metaboxes from the post editor screen:

  • To Reduce Clutter: The most common reason is simply to create a cleaner, more streamlined writing interface. Hiding unused boxes removes visual noise and helps you focus on your content.
  • To Simplify the User Experience: If you are building a site for a client, you might want to hide advanced options they don’t need. This prevents them from accidentally changing important settings and makes the dashboard less intimidating.
  • To Improve Page Load Speed: While the impact is usually small, having a large number of metaboxes can slightly increase the load time of the editor screen. Removing unnecessary ones can contribute to a snappier admin experience.
  • To Enforce a Workflow: You might want to prevent certain user roles from accessing specific features. For instance, you could hide the “Publish” metabox for contributors, forcing them to submit posts for review instead.

Now, let’s explore the different ways you can hide these metaboxes.

Method 1: The Easy Way with Screen Options

Before diving into code, it’s important to know about the built-in WordPress feature for managing your editor screen. This method is user-specific, meaning the changes will only apply to your own user account.

  1. Navigate to the Post Editor: From your WordPress dashboard, go to Posts > Add New.
  2. Open Screen Options: In the top-right corner of the screen, you will see a tab labeled “Screen Options.” Click on it.
  3. Uncheck the Metaboxes: A panel will drop down, showing a list of all available metaboxes on the screen. Simply uncheck the box next to each metabox you want to hide.

The changes are saved instantly. The unchecked boxes will disappear from your editor, giving you a cleaner workspace. This is the simplest and safest way to hide a metabox for your personal use.

Method 2: Hiding Metaboxes for All Users with Code

If you want to hide metaboxes for all users or specific user roles, you’ll need to add a small snippet of code. This is the best approach for developers or site administrators who want to enforce a consistent editor experience across the entire site.

You will be using the remove_meta_box() WordPress function. This function requires two main parameters: the ID of the metabox you want to remove and the screen where it appears (in our case, post).

You can add this code to your theme’s functions.php file or, for better practice, use a site-specific plugin.

Warning: Always back up your functions.php file before making any edits. An error in this file can take down your entire website.

Step 1: Find the Metabox ID

To remove a metabox, you first need to know its unique ID. The easiest way to find it is by using your web browser’s developer tools.

  1. Go to the Posts > Add New screen in WordPress.
  2. Right-click on the title bar of the metabox you want to hide and select Inspect or Inspect Element.
  3. The developer tools console will open, highlighting the HTML for that element. Look for the div element with a class of postbox. Its id attribute is the metabox ID you need.

Common metabox IDs include:

  • submitdiv (Publish box)
  • categorydiv (Categories)
  • tagsdiv-post_tag (Tags)
  • postimagediv (Featured Image)
  • postexcerpt (Excerpt)
  • trackbacksdiv (Send Trackbacks)
  • commentstatusdiv (Discussion)
  • commentsdiv (Comments)
  • slugdiv (Slug)
  • authordiv (Author)

Plugin-specific IDs will vary. For example, a Yoast SEO metabox ID is often yoast_wpseo_metabox.

Step 2: Add the Code to Hide the Metabox

Once you have the ID, you can use the remove_meta_box() function. The code should be wrapped in a function that hooks into the add_meta_boxes action.

Here is a sample code snippet. You can copy and paste this into your theme’s functions.php file or a site-specific plugin.

function my_remove_metaboxes() {
// Hide the "Tags" metabox
remove_meta_box('tagsdiv-post_tag', 'post', 'side');

// Hide the "Excerpt" metabox
remove_meta_box('postexcerpt', 'post', 'normal');

// Hide the "Trackbacks" metabox
remove_meta_box('trackbacksdiv', 'post', 'normal');
}
add_action('add_meta_boxes', 'my_remove_metaboxes');

Let’s break down the remove_meta_box() function:

  • 'tagsdiv-post_tag': This is the ID of the metabox we are removing.
  • 'post': This specifies the screen to remove it from (the post editor). You could also use 'page' for pages or a custom post type name.
  • 'side': This is the context, or where the box is located. The options are 'normal' (main column), 'side' (sidebar), and 'advanced'.

You can add as many remove_meta_box() lines as you need within the my_remove_metaboxes function to hide multiple elements.

Example: Hiding a Plugin Metabox

Let’s say you want to hide the metabox from a popular SEO plugin. After using the “Inspect” tool, you find its ID is some_seo_plugin_metabox. The code would look like this:

function my_hide_plugin_metaboxes() {
// Hide the metabox from an SEO plugin
remove_meta_box('some_seo_plugin_metabox', 'post', 'normal');
}
add_action('add_meta_boxes', 'my_hide_plugin_metaboxes');

This code will remove the specified plugin metabox from the post editor for all users.

Best Practices for Managing Metaboxes

Customizing the WordPress dashboard is a powerful way to improve your workflow. Here are a few final tips for managing metaboxes effectively:

  • Use a Child Theme or Site-Specific Plugin: Instead of editing your theme’s functions.php file directly, add customizations to a child theme or a site-specific plugin. This ensures your changes are not lost when you update your parent theme.
  • Hide, Don’t Disable: The code we used hides the metaboxes from view, but it doesn’t disable their functionality. The features associated with them still work in the background. This is generally safer than trying to deregister plugin features entirely.
  • Consider User Roles: For more advanced control, you can wrap your code in a conditional check to hide metaboxes only for certain user roles (e.g., ‘author’ or ‘contributor’). This allows you to provide a simplified interface for some users while giving administrators full access.
  • Keep it Simple: The goal is to make things easier, not more complicated. Only hide what is truly unnecessary. A well-organized screen with a few essential tools is often better than a completely empty one.

By taking control of your editor screen, you can create a more pleasant and productive content creation environment in WordPress. Whether you use the simple “Screen Options” toggle or a custom code snippet, decluttering your post-new.php screen is a straightforward process that yields immediate benefits.

Leave a Reply

Your email address will not be published. Required fields are marked *