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.

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?

share|improve this question

2 Answers 2

up vote 7 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');
share|improve this answer
    
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

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' );
share|improve this answer

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.