I have a custom post type (called contacts). Since this post type is not working like a post, I don't want to show SAVE DRAFT, PREVIEW, Status, Visibility or Publish Date.

The only options I want to show are PUBLISH & Move to Trash buttons.

Is there a way to hide these other options? If not, how do I create a new PUBLISH & Move to Trash that I can add to a new metabox?

up vote 13 down vote accepted

You can simply hide the options using CSS. This will add a display:none style to the misc and minor publishing actions on the post.php and post-new.php pages. It checks for a specific post type as well since all post types use these two files.

function hide_publishing_actions(){
        $my_post_type = 'POST_TYPE';
        global $post;
        if($post->post_type == $my_post_type){
            echo '
                <style type="text/css">
                    #misc-publishing-actions,
                    #minor-publishing-actions{
                        display:none;
                    }
                </style>
            ';
        }
}
add_action('admin_head-post.php', 'hide_publishing_actions');
add_action('admin_head-post-new.php', 'hide_publishing_actions');
  • Brian - Thanks for the quick response. I tried the function, replacing 'POST_TYPE' with the name of the custom post type (contacts), but nothing is removed when I go the the edit/add new pages. – katemerart Dec 11 '11 at 3:27
  • Check out my latest edit. It should fix the issue. :) – Brian Fegter Dec 11 '11 at 3:49
  • That is brilliant - this has opened up a whole new way to remove stuff I don't want showing!! Thank you so much. – katemerart Dec 11 '11 at 4:13
  • Glad to help out :) – Brian Fegter Dec 11 '11 at 4:25
  • Just to point it out: you can remove a level of indentation for your code by simply doing if ( $post->post_type != $my_post_type ){ return; } at the beginning. No need to have the entirety of your code wrapped in the if statement. – Pete Dec 27 '16 at 23:27

In this example you can easily set on which post types you want to hide the publishing options, the example hides them for the build-in pots type type page and the custom post type cpt_portfolio.

/**
 * Hides with CSS the publishing options for the types page and cpt_portfolio
 */
function wpse_36118_hide_minor_publishing() {
    $screen = get_current_screen();
    if( in_array( $screen->id, array( 'page', 'cpt_portfolio' ) ) ) {
        echo '<style>#minor-publishing { display: none; }</style>';
    }
}

// Hook to admin_head for the CSS to be applied earlier
add_action( 'admin_head', 'wpse_36118_hide_minor_publishing' );

Important update

I would also suggest you force a post status of "Published" to avoid saving posts as drafts:

/**
 * Sets the post status to published
 */
function wpse_36118_force_published( $post ) {
    if( 'trash' !== $post[ 'post_status' ] ) { /* We still want to use the trash */
        if( in_array( $post[ 'post_type' ], array( 'page', 'cpt_portfolio' ) ) ) {
            $post['post_status'] = 'publish';
        }
        return $post;
    }
}

// Hook to wp_insert_post_data
add_filter( 'wp_insert_post_data', 'wpse_36118_force_published' );

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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