likwidmonster likwidmonster - 1 year ago 112
PHP Question

Remove Metabox on Wordpress pages

I would like to remove the metabox on pages with certain slugs. Is this possible?

I have seen the remove_meta_box() function but cannot seem to get it to work.

This is the box I am trying to remove:

enter image description here

Thank You!

Answer Source

It's not a meta_box you want to remove, it's the 'editor,' which is a feature of posts. You'll want to use remove_post_type_support()


add_action( 'admin_head', 'custom_remove_editor' );

function custom_remove_editor() {
  global $post;
  $post_id = $post->ID

  if( $post_id == 1 || $post_id == 2 || $post_id == 3 ) {
   remove_post_type_support( 'post', 'editor' );

Of course, the numbers in the if() statement should match the post_ids you want this to be removed on.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download