How to remove Custom Field section from WordPress?

I am trying to remove custom fields section from WordPress backend. I think I found a function that display custom fields. The function is located in wp-admin/edit-page-form.php line 181.

do_meta_boxes('page','normal',$post)

when I remove the function, WordPress does not display other boxes as well.

Read More

How do I remove a particular box from WordPress backend?

Related posts

Leave a Reply

4 comments

  1. function remove_metaboxes() {
     remove_meta_box( 'postcustom' , 'page' , 'normal' ); //removes custom fields for page
     remove_meta_box( 'commentstatusdiv' , 'page' , 'normal' ); //removes comments status for page
     remove_meta_box( 'commentsdiv' , 'page' , 'normal' ); //removes comments for page
     remove_meta_box( 'authordiv' , 'page' , 'normal' ); //removes author for page
    }
    add_action( 'admin_menu' , 'remove_metaboxes' );
    

    change “page” to “post” to do this for posts

    Put this in your function.php file

  2. This is how to do it for all post types:

    add_action( 'do_meta_boxes', 'remove_default_custom_fields_meta_box', 1, 3 );
    function remove_default_custom_fields_meta_box( $post_type, $context, $post ) {
        remove_meta_box( 'postcustom', $post_type, $context );
    }
    
  3. You can most easily do this by editing the CSS for the individual box within the admin. First method that comes to mind would be to add the following to your theme’s functions.php file.

    <?php
    add_action('wp_head','hide_custom_fields_postbox');
    
    function hide_custom_fields_postbox()
    {
      if ( is_admin() ) {
      ?>
      <style type="text/css">
      div#postcustom {display:none;}
      </style>
      <?php
      }
    }//end function
    ?>