Support

Account

Home Forums ACF PRO Field Key Difference ACF4/5

Solved

Field Key Difference ACF4/5

  • Just a heads up for anyone that may have done the same in the past.

    Working on upgrading plugins I noticed a difference in the requirements for field keys. Field keys in ACF5 must start with “field_” whereas in ACF4 this could be changed. When building a plugin I would generally alter the field key to begin with an underscore which would those fields from the custom fields field selector.

    However, since the field key values no longer appear to be stored in the postmeta table, or anywhere for that matter, I don’t suppose I need to do that any more.

    • Elliot

    • July 15, 2014 at 10:55 am

    Hi @hube2

    Thanks for the topic, however I can confirm that in version 4, the field key must also start with ‘field_’.

    I am not sure how you were able to edit this information and allow ACF to continue working, but I don’t recommend it.

    P.S. ACF now save’s field setting data in the wp_posts table! post_type = ‘acf-field’

    Thanks
    E

  • I find that extremely interesting. For example, this is a field I created for a plugin for ACF4

    
    array('key' => '_acf_key_acfop_menu',
          'label' => 'Menu Text',
          'name' => '_acfop_menu',
          'type' => 'text',
          'instructions' => 'Will default to title if left blank.',
          'default_value' => '',
          'placeholder' => '',
          'prepend' => '',
          'append' => '',
          'formatting' => 'none',
          'maxlength' => '')
    

    I was thinking to myself… “It would be nice if all those fields didn’t appear in the ‘Custom Fields’ drop down in WP”… so I tried changing them to start with an underscore. When that worked I just started changing the “key” value to whatever I wanted and that worked.

    If this is a bug in ACF4 I would ask that it’s a bug you ignore. 😛

    ~JH

  • @E “ACF now save’s field setting data in the wp_posts table! post_type = ‘acf-field’”

    Which is why I couldn’t find them searching the postmeta table. If the field keys aren’t stored there then they won’t appear in the list of custom fields, so you fixed my issue.

    If there are any issues with the field names in ACF4 in the future I’ll just fix them but since I’m trying to get everything updated to work with 5, ehh *shrugs shoulders* 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

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.