3

I want to hide certain panels in the dashboard, for example the Excerpt panel. This metabox has an id of postexcerpt.

Is it a good idea to simply add some CSS rule like #postexcerpt { display: none } in the admin's CSS? Or may this cause hidden problems down the line?

2

@joesk isn't quite correct. If you simply want to hide a meta box or two on the post-editing screen, you can do that via the Screen Options tab at the top of most screens.

If it's not aesthetic to your personal preferences and you'd like to remove the ability to edit the Excerpt at all, you have two options:

1) Remove the 'excerpt' support from your post type:

/**
 * Remove 'excerpt' support from the 'post' post type.
 */
function wpdocs_remove_posts_excerpt_support() {
    remove_post_type_support( 'post', 'excerpt' );
}
add_action( 'admin_init', 'wpdocs_remove_posts_excerpt_support' );

2) Remove the meta box (retaining post type support):

/**
 * Remove the Excerpt meta box from the 'post' editing screen.
 * 
 * This does not remove the 'excerpt' post type support, simply hides the meta box for all.
 */
function wpdocs_remove_excerpt_meta_box() {
    remove_meta_box( 'postexcerpt', 'post', 'normal' );
}
add_action( 'add_meta_boxes', 'wpdocs_remove_excerpt_meta_box' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.