Disable “preview changes” button

Please replace $post_type with your post_type in question, e.g. post, page, cpt_slug,…

The function echoing the meta box with the preview button is called post_submit_meta_box. The condition to show the button is set with the function is_post_type_viewable. Following that: If the {$post_type}s flags publicly_queryable or _builtin and public are set to true the preview button will be shown. That means all publicly queryable built-in post types will have that button anyway. For CPTs you can adapt the flags, if you don’t need them publicly queryable.

What if I want to publicly query my $post_type, but don’t want a preview button?

You are out of luck for an easy solution. But there is always a workaround:

  1. Hide the Button with custom CSS that you load on condition of screens post.php/post-new.php and your $post_type.
  2. Hide the Button with JS on the same condition.
  3. Remove the meta box and replace it with your own. Here some code to get you started.

    function add_custom_submit_box() {
        $publish_callback_args = null;
        //TODO: Add revisions support if needed, see wp-admin/edit-form-advanced.php Line 219 if needed.
        remove_meta_box( 'submitdiv', $post_type, 'side');
        add_meta_box( 'submitdiv', __( 'Publish' ), 'my_{$post_type}_submit_meta_box', $post_type, 'side', 'core', $publish_callback_args );
    }
    
    add_action('init','add_custom_submit_box');
    
    function my_{$post_type}_submit_meta_box( $post, $args = array() ) {
        //TODO: Copy & paste post_submit_meta_box function and adapt to your needs.
    }