2

How can I completely remove the custom fields and the collapse button in the Edit Post/Edit Page custom screen, but without removing the capability to add custom fields with a PHP function?

2 Answers 2

5

http://codex.wordpress.org/Function_Reference/remove_meta_box

function remove_custom_meta_form() {
    remove_meta_box( 'postcustom', 'post', 'normal' );
    remove_meta_box( 'postcustom', 'page', 'normal' );
}
add_action( 'admin_menu' , 'remove_custom_meta_form' );

HTH

1
  • glad I could help
    – nvwd
    Commented Jul 27, 2012 at 16:29
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 );
}
1
  • Thankfully, this works for the block editor, too! Commented Aug 4, 2022 at 16:37

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.