Wordpress: Hide Admin Meta Boxes


/ Published in: PHP
Save to your folder(s)

Remove meta boxes from the Wordpress admin area. Useful for simplifying Wordpress' admin interface for your clients. Add this snippet to your Wordpress theme's functions.php file.


Copy this code and paste it in your HTML
  1. /**
  2.  * Remove meta boxes.
  3.  */
  4. function remove_meta_boxes() {
  5. // Only proceed if user does not have admin role.
  6. if (!current_user_can('manage_options')) {
  7. remove_meta_box( 'submitdiv', 'post', 'normal' ); // Publish meta box
  8. remove_meta_box( 'commentsdiv', 'post', 'normal' ); // Comments meta box
  9. remove_meta_box( 'revisionsdiv', 'post', 'normal' ); // Revisions meta box
  10. remove_meta_box( 'authordiv', 'post', 'normal' ); // Author meta box
  11. remove_meta_box( 'slugdiv', 'post', 'normal' ); // Slug meta box
  12. remove_meta_box( 'tagsdiv-post_tag', 'post', 'side' ); // Post tags meta box
  13. remove_meta_box( 'categorydiv', 'post', 'side' ); // Category meta box
  14. remove_meta_box( 'postexcerpt', 'post', 'normal' ); // Excerpt meta box
  15. remove_meta_box( 'formatdiv', 'post', 'normal' ); // Post format meta box
  16. remove_meta_box( 'trackbacksdiv', 'post', 'normal' ); // Trackbacks meta box
  17. remove_meta_box( 'postcustom', 'post', 'normal' ); // Custom fields meta box
  18. remove_meta_box( 'commentstatusdiv', 'post', 'normal' ); // Comment status meta box
  19. remove_meta_box( 'postimagediv', 'post', 'side' ); // Featured image meta box
  20. remove_meta_box( 'pageparentdiv', 'page', 'side' ); // Page attributes meta box
  21. }
  22. }
  23. add_action( 'add_meta_boxes', 'remove_meta_boxes' );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.