I use Magic Field 2 to display custome field on my page !

However, I would like to be able to hide several field depending on the page ID...

I do not want to use custom post type because my website rely on basic page.

Any idea on how I could do that ? Using javascript perhaps ?

I can't figure out, which hook I should use.

Thanks in advance for your time and patience.



  • a single field within a meta box, or whole meta boxes?
    – Milo
    Apr 27, 2012 at 15:10
  • A whole meta box if it's possible.
    – Nypam
    Apr 28, 2012 at 6:46
  • see my answer below.
    – Milo
    Apr 28, 2012 at 23:26

1 Answer 1


You can remove meta boxes with the remove_meta_box function:

function wpse50430_remove_meta_boxes() {

    // make sure we're on an admin screen and `post` is set
    if( !is_admin() && !isset( $_GET['post'] ) )

    if( $_GET['post'] == 99 ): // editing page ID 99
        remove_meta_box( 'pageparentdiv', 'page', 'normal' );

add_action( 'admin_menu', 'wpse50430_remove_meta_boxes' );

To remove meta boxes added by plugins, you have to find the handle ID. If you use Chrome's developer tools, you can right-click the meta box and look for the ID of the element with class postbox.

  • Hi Milo, it is weird because it doesn't work... I got no error, I double check the ID of the meta box. I even tried with an other meta box. Thanks in advance.
    – Nypam
    Apr 29, 2012 at 9:28
  • Ok it works if I replace admin_menu by admin_head !
    – Nypam
    Apr 29, 2012 at 9:31
  • @Jk_ add_action also has a priority parameter you can change, it's possible the meta boxes were being added after you're trying to remove them in admin_menu.
    – Milo
    Apr 29, 2012 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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