Home › Forums › Feature Requests › Meta Key Values in Custom Field Dropdown › Reply To: Meta Key Values in Custom Field Dropdown
1 – For all of the custom fields that I control the naming of, I prefixed the key with an underscore (i.e. “_my_custom_field”). This prevents them from being displayed in WordPress’ custom fields drop-down list.
2 – For the custom fields that ACF automatically generates (i.e. when using tabs, ACF uses the “field_51” prefix on the site that I’m working on), I wrote some PHP:
if(!function_exists(‘kc_hide_meta_keys_start’)){
function kc_hide_meta_keys_start( $num ){
add_filter( ‘query’, ‘kc_hide_meta_keys_filter’ );
return $num;
}
add_filter( ‘postmeta_form_limit’, ‘kc_hide_meta_keys_start’ );
}
if(!function_exists(‘kc_hide_meta_keys_filter’)){
function kc_hide_meta_keys_filter( $query ){
remove_filter( current_filter(), __FUNCTION__ );
// Match keys beginning with field_51
$where = “WHERE meta_key NOT LIKE(‘field_51%’);
$find = “GROUP BY”;
$query = str_replace( $find, “$where\n$find”, $query );
return $query;
}
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.