1

Is there any way, how to remove "Publish metabox" from each post type (post,page,custom_post_type) anything.

I know how to remove it manually, for each post type, but how to do it globally?

remove_metabox(...)

1 Answer 1

4

If you're familiar with Browser Developer Tools you can quickly find the metabox ID ( which is the container div id ). In this case it's called submitdiv. We can remove it by using the remove_meta_box() function which has a format like this:

remove_meta_box( 'metabox_id', 'post_type', 'default_position' );
remove_meta_box( 'submitdiv',  'post',      'side'             );

Here's a list of default metabox ids. If we want to remove a certain metabox from all post types we first need to get all the post types using get_post_types() function which returns an array. Then we can loop through and remove the metabox passing the post_type into our remove_meta_box() function.

/**
 * Hide Metaboxes For All Post Types
 */
function hide_publish_metabox() {
    $post_types = get_post_types( '', 'names' );

    if( ! empty( $post_types ) ) {
        foreach( $post_types as $type ) {
            remove_meta_box( 'submitdiv', $type, 'side' );
        }
    }
}
add_action( 'do_meta_boxes', 'hide_publish_metabox' );
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.