Created
September 20, 2024 15:10
-
-
Save cccamuseme/2e29cbe11664af1a04b937551e2ecaca to your computer and use it in GitHub Desktop.
Hide a meta box in WordPress. Customize the code and add to you themes functios file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Open your theme's functions.php file or create a custom plugin. | |
// Add the following code: | |
Add the following code: | |
function remove_custom_meta_boxes() { | |
// Example: remove the 'slugdiv' meta box from the post editor screen | |
remove_meta_box('slugdiv', 'post', 'normal'); | |
// Add more meta boxes to remove, if necessary | |
// Example: remove 'authordiv' meta box from pages | |
remove_meta_box('authordiv', 'page', 'normal'); | |
} | |
add_action('admin_menu', 'remove_custom_meta_boxes'); | |
// 'slugdiv' is the ID of the meta box you want to remove. | |
// 'post' or 'page' is the post type. | |
// 'normal' defines the context of the meta box (can also be 'side' or 'advanced'). | |
// You can use this approach to hide any meta box by specifying its ID. If you don’t know the ID of a meta box, you can inspect the page’s HTML in the WordPress admin to find it. | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment