Support

Account

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;
    }
    }