When you use a standard custom field in WP you have to write the name of the cusotm fields the first time.

The second time you use a custom field it sticks to the custom fields dropdown list. But, sometimes when you install plugins they ise ALOT of custom fields.

This list becomes a bit long an it may "push" som of my custom fields out of tghe list. So, does anyone know how I can remove custom fields from my dropdown list in any easy way?

2 Answers 2


You can filter the query for these keys on'query'. I would start that filter as late as possible to avoid side effect.

Sample code, tested:

add_filter( 'postmeta_form_limit', 'wpse_73543_hide_meta_start' );

function wpse_73543_hide_meta_start( $num )
    add_filter( 'query', 'wpse_73543_hide_meta_filter' );

    return $num;

function wpse_73543_hide_meta_filter( $query )
    // Protect further queries.
    remove_filter( current_filter(), __FUNCTION__ );

    $forbidden = array ( 'the', 'keys', 'you', 'want', 'to', 'hide' );
    $where     = "WHERE meta_key NOT IN('" . join( "', '", $forbidden ) . "') ";
    $find      = "GROUP BY";
    $query     = str_replace( $find, "$where\n$find", $query );

    return $query;
  • then what is the purpose of the meta_form function found in wp-admin/includes/template.php? it doesn't appear to use the is_protected_meta filter.
    – Milo
    Nov 21, 2012 at 23:59
  • @Milo No, that happens before meta_form(); is reached. I have added that function to my answer.
    – fuxia
    Nov 22, 2012 at 0:06
  • I think that's just to disallow editing of meta data that a user doesn't have permission to modify, it appears meta_form is where the dropdown is created via a direct sql query of existing keys.
    – Milo
    Nov 22, 2012 at 0:13
  • @Milo You were right, I have rewritten my answer completely. Thanks for the hints. :)
    – fuxia
    Nov 22, 2012 at 0:34

There isn't a way to filter what appears there, you can see where it queries for keys and renders that field in the function meta_form() in wp-admin/includes/template.php, however you can see that it ignores any key prefixed with an underscore:

HAVING meta_key NOT LIKE '\_%'

this is what plugins should be doing with any meta keys they create to hide those keys from the menu.

You'll also see a filter in there, postmeta_form_limit, which is set to 30 by default. You could increase this number so your keys at least get included in the list and don't fall off the end.

Another option is to create your own meta box to manage specific meta data, rather than using the Custom Fields meta box.

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.