Disable dragging of metaboxes in custom post types?

I am able to disable dragging of metaboxes sitewide with this function:

function disable_drag_metabox() {
wp_deregister_script(‘postbox’);
}
add_action( ‘admin_init’, ‘disable_drag_metabox’ );

But I want it only on a custom post type.
I tried the usual:

function disable_drag_metabox() {
global $current_screen;
if( ‘event’ == $current_screen->post_type ) wp_deregister_script(‘postbox’);
}
add_action( ‘admin_init’, ‘disable_drag_metabox’ );

and also this one:

function disable_drag_metabox() {
$screen = get_current_screen();
if( in_array( $screen->id, array( ‘event’ ) ) ) {
wp_deregister_script(‘postbox’);
}
}
add_action( ‘admin_init’, ‘disable_drag_metabox’ );

Sadly it doesn’t work. What am I doing wrong? the custom post type is called event.

Read more here:: Disable dragging of metaboxes in custom post types?

Leave a Reply

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