But shouldn’t that mean that the field key hasn’t been saved to the meta table either at that point? To my knowledge the field key is only saved in one location (for wp_postmeta) and that is as the value of _field_name.
Sorry, I didn’t understood you before; you mean the post_id of the post that acf creates? That makes sense; but I have different versions of the db for each server so the ID is not the same for all, I guess I could make a query to find it out but that would be more work for the same result.
What I mean is that whenever ACF saves a value for the first time on a post two fields is created in wp_postmeta. Both field_name and _field_name where field_name contains the actual value and _field_name contains the fields internal key created by ACF.
So if field_name exists in wp_postmeta then _field_name should also exist. The exemption from this is if you create the field_name key/value pair yourself using update_post_meta (for example). Then _field_name wont exist until the post has been “updated” from wp-admin.
Viewing 6 posts - 1 through 6 (of 6 total)
The topic ‘Getting the field_key by name’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users