How To Remove Post Preview Button From WordPress Post Editor

Are you working on a site or with custom post types where you don’t need post preview button? Here’s how to remove post preview button from post editor.

Just drop the following snippet to your current theme’s functions.php file:

function posttype_admin_css() {
    global $post_type;
    $post_types = array(
                        /* set post types */
    if(in_array($post_type, $post_types))
    echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
add_action( 'admin_head-post-new.php', 'posttype_admin_css' );
add_action( 'admin_head-post.php', 'posttype_admin_css' );

In the $post_type arrow you can define in which post types you want to remove post preview button.

Leave a Comment