Customize Edit Post screen for Custom Post Types?

Some of these questions are answered here: Set Default Admin Screen options & Metabox Order

To remove the permalink metabox:

function my_remove_meta_boxes() {
    remove_meta_box('slugdiv', 'my-post-type', 'core');
}
add_action( 'admin_menu', 'my_remove_meta_boxes' );

additionaly, you will have to hide #edit-slug-box with css or javascript. see: Loading External Scripts in Admin but ONLY for a Specific Post Type?

To disable quick edit:

function my_remove_actions( $actions, $post ) {
    if( $post->post_type == 'my-post-type' ) {
        unset( $actions['inline hide-if-no-js'] );
    }
    return $actions;
}
add_filter( 'post_row_actions', 'my_remove_actions', 10, 2 );

To change the preview link, you could use the filter ‘preview_post_link’, but it works only when the post has not yet been published.
So, the solution would be to remove the submit meta box and add your own modified one:

function my_replace_submit_meta_box() {
    remove_meta_box('submitdiv', 'my-post-type', 'core');
    add_meta_box('submitdiv', __('Publish'), 'custom_post_submit_meta_box', 'my-post-type', 'side', 'core');
}
add_action( 'admin_menu', 'my_replace_submit_meta_box' );

function custom_post_submit_meta_box() { // a modified version of post_submit_meta_box() (wp-admin/includes/meta-boxes.php, line 12)
    ...
}

Leave a Comment