Monday, October 1, 2012

Hide post view and post preview admin buttons

Ever wanted to remove “preview & view” options from the new post and post edit admin screens. Add this code 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".
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 '';
}
add_action( 'admin_head-post-new.php', 'posttype_admin_css' );
add_action( 'admin_head-post.php', 'posttype_admin_css' );

    echo
'<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>'

No comments:

Post a Comment