Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

What's the best way to completely customize the Edit Post admin screen for a specific custom post type?

I have customized it to an extent already on creation of the custom post type - adding additional fields etc, but I want to remove many of the elements such like permalinks, preview post, disable quick editing etc

share|improve this question
add comment

1 Answer

up vote 15 down vote accepted

Some of these questions are answered here: http://wordpress.stackexchange.com/questions/1390/set-default-admin-screen-options-metabox-order/1402#1402

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: http://wordpress.stackexchange.com/questions/1058/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)
    ...
}
share|improve this answer
    
Thanks so much. Been searching for the answer to this for ages! Also, is there a way to change where the Preview button in the Publish box links to? I'd like it to link to mysite.com/video?id='id of post' or open up a lightbox with a video player –  fxfuture Sep 28 '10 at 5:07
    
Hi again - actually I can't get either of those bits of code you supplied to work. The permalink metabox just disables saving changes to the permalink rather than hiding it, and I can't disable the Quick Edit link at all. Any ideas? –  fxfuture Sep 28 '10 at 6:40
    
I edited my answer. I just tested the quick edit code ad it works. You are talking about the quick edit link below the post name on: wp-admin/edit.php?post_type=sis_course, right? –  sorich87 Sep 28 '10 at 7:07
    
Great, I'll have a look at the additional info you posted. I was able to hide the quick edit by changing 'hierarchical' => false in my custom post type. Doesn't seem to make a difference as I'm using the Post Types Order plugin to order it anyway. Thanks! –  fxfuture Sep 28 '10 at 7:35
    
You are welcome. –  sorich87 Sep 28 '10 at 9:25
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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