Hiding the Preview Button in WordPress
WordPress is good for its simplicity for clients, who do not want to understand the admin panel when adding their articles, but even here you can remove elements that are rarely used.
Today I will tell you how to remove the preview button of the current post from the page for adding a new article., which, as far as I know, no one really uses.
Simple code example:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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' ); |
If you do not want to remove the current page view button, you can change the code a little and instead of the line:
1 2 3 |
<p> echo '<br /> <style type="text/css">#post-preview, #view-post-btn{display: none;}</style> <p>';</p> |
write another:
1 2 3 |
<p>echo '<br /> <style type="text/css">#post-preview{display: none;}</style> <p>'; </p> |
Using the same method, you can remove almost any element in the admin area., but be careful, you just hide the elements and do not prohibit their use and malicious hackers can take advantage of this ).
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.