wordpress snippets last updated   : April 14, 2014
we now have 630 snippets

Hide post view and post preview admin buttons

wordpress snippet

Ever wanted to remove “preview & view” options from the new post and post edit admin screens. Add this snippet to the functions.php of your wordpress theme and don’t forget to update the post type array. Enter any post type you would like to remove the “view and preview” buttons from “custom post type, post, page”.

snippet :  PHPcopy
function posttype_admin_css() {
    global $post_type;
    $post_types = array(
                        /* set post types */
			'post_type_name',
			'post',
			'page',
		  );
    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' );

  • Nick Powers

    Thanks!

    Do you know how I might be able to get rid of the “Post updated View post” message when I publish/update a custom post type that I’ve created? My plugin has an internal use for the CPT and it is not indented to ever be displayed, so when users click that they get a 404 page. I’d love to get rid of the link all together.

    Thanks again,

    Nick

jqsnipp.com | we just launched jquery snippets website