Remember Apple’s “Goto Fail”?
Similar situation:
Your code actually does this, when indentation is corrected:
foreach ( $post_types as $post_type )
remove_meta_box('trackbacksdiv', $post_type, 'normal');
remove_meta_box('postcustom', $post_type, 'normal');
remove_meta_box('authordiv', $post_type, 'normal');
remove_meta_box('postexcerpt', $post_type, 'normal');
So, it should does the job for trackbacksdiv, but not for the rest because the function calls are outside of the foreach and $post_type is not defined.
If you replace $post_type with post it works, because..well, the function arguments are complete.
Wrap your foreach in { } and try it again.
Related Posts:
- Prevent sorting and dragging of specific postbox metabox
- Why can’t I hook into save_posts after admin_init?
- Why is `add_meta_box` not working?
- How to access global $wp_meta_boxes variable on front-end?
- prevent post submission
- Select box saves but doesn’t update value in admin
- Resetting admin post form on JS validation fail
- How to prevent further updates of custom meta when using actions to set one meta based on another
- Add custom action in post type
- How to position user meta data field
- meta box on new admin page
- Why do Metabox use Nonces?
- save_post_{$post->post_type} action firing on second save
- Remove meta box except on category pages
- WP admin display custom field if another field value is “Female”
- Error showing in current page id in wordpress admin
- Remove menu item dashboard for a unique user
- Hooking into the Meta Boxes (Name/Web Address/Description) on the ‘Add New Link’ Page
- How do I Enqueue styles/scripts on Certain /wp-admin Pages?
- How to remove admin menu pages inserted by plugins?
- Changing Admin Menu Labels
- Create more Meta Boxes as needed
- Is there ANY way to remove comments function and section totally?
- Set Default Admin Screen options & Metabox Order
- How to set default screen options?
- Passing error/warning messages from a meta box to “admin_notices”
- Placing a Custom Post Type Menu Above the Posts Menu Using menu_position?
- Disable dragging of meta boxes?
- Add “upload media” button in meta box field
- Add a Meta Box for uploading a SECOND Featured Image?
- Does WordPress have a “Form API”?
- Metabox with checkbox is not updating
- How to HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button
- What is the “Advanced” $context in add_meta_box?
- How to Add a Third Level Sub Menu to the WordPress Admin Menu
- Removing panels (meta boxes) in the Block Editor
- Change The Title Of a Meta Box
- WordPress SEO by Yoast: Hide Meta Boxes in Posts for Non-admins
- Displaying the number of updates available in the Admin area
- How to make open/closed and hidden/shown metaboxes status saved on a per-post basis?
- How To Remove The “+ Add New Category” Link From A Category Metabox
- Taxonomy dropdown metabox in the back-end
- Meta Boxes: ‘admin_init’ or ‘add_meta_boxes’ hook?
- How can I create a taxonomy meta-box with search suggestions but no new terms input?
- Remove the Featured Image Meta Box
- Remove the Yoast SEO Post Metabox [closed]
- Best practices for meta box placement?
- Creating a metabox to upload multiple images
- Remove “posts” from admin but show a custom post
- How Does WordPress Remember Metabox Positions?
- Sample code for validating custom metabox?
- Using TinyMce with textareas in meta boxes on custom post types
- Post custom metabox textarea using wp_editor
- How to Add Reminders/Notes to New Post Meta Boxes
- How do I get attachment_id?
- Removing Metabox for “Slug” without removing functionality
- Add “external” link to admin menu in the backend
- How to reorder meta box position?
- wp_list_tables bulk actions
- One metabox for multiple post types
- How do I position meta_box on post edit screen after the title?
- Admin menu as submenu from another plugin
- How to add a class to meta box
- How to add custom submenu links in wp-admin menus?
- Remove unusable metaboxes in nav menu management screen
- Has anyone successfully integrated qtranslate with custom metaboxes?
- Action hook on Edit custom post type?
- Put the media uploader in a metabox
- Custom Meta Boxes: multiple fields within a repeatable field
- Removing an admin page added by a 3rd party plugin. Gravity forms in this example
- Edit specific nodes in WP_Admin_Bar
- Removing meta boxes: remove-meta_box() or unset()?
- Is it OK to move admin menu items?
- How to add notification bubble for my custom admin menu page
- Save checkbox value in metabox
- How to create sub menu with a URL parameter?
- How to group meta boxes on the post edit page
- Use meta box drag and drop to order items independently
- inside a metabox
- Add Meta box Befoure Post Title
- Is it possible to add an admin page using add_submenu_page() and pass a var in the query string?
- Remove Pagination in Appearance -> Menus -> Categories
- Adding a menu item in the admin bar
- Hiding a theme’s meta box
- Metabox date month number to word
- get registered metaboxes by post type or post ID
- Remove metabox from specific page template in admin
- Is there a filter/action to add content to WP admin metaboxes?
- Attach Files Metabox
- CMB2 metabox conditional logic
- Better way to enforce category hierarchy in post_categories_metabox?
- WordPress admin notice in plugin function
- Tinymce/WordPress is removing all line-breaks?
- How do I create a meta box for dates?
- Adding submit or update button to custom metabox?
- How to remove items from +New admin menu?
- Reorder custom submenu item
- Editing the Default Links like “Site Admin” in the Sidebar Meta Section?
- How to pass variable via $callback_args for add_meta_box
- Appearance->Editor not visible