You can get the field key in the admin where you create the fields <- this is a nogo, overkilling workflow for a deployment script.
Unfortunately, my expected behavior on updating an existent POST / un-existent custom field in production, did not caused an issue and correctly created the field reference “field_5ac3e34638087”.
So I am still confused when we HAVE TO use the field for updating records.
The only scenario left I could think of, is when the field does not exist at all, and then you try to update it, then it would make sense to go and create one manually or programatically, and then update it.
Thnks for any comment you may have on this.
Yes, I used to have a project where I definitely used the field references and it was a mess, because the site lived in a local, test, stage and production environments, and obviously the field hashes didnt match at all, so update script files had to be updated frequently. I was just hoping to find an easy way to handle this. I also didn’t find any api function to get the field reference name, do we have to look for it always in the database? or there is a special function to get it?
Hey John!, thankx for your response. I totally understand what you are saying, but I am in fact doing everything in code. (there is no update button).
Maybe the only situation you might be refering to, is when the field was created at a later stage, then updated the post throught the admin, then delete the two rows from the database, and then update it again in code. <- this is what I did in my local environment, and as I said the fields created without issues.
What I am going to do next is to update with code in my remote environment without adding the field data in the post, then check if there is an issue. <- this has to be the cleanest, non-existent data-field whatsoever. (I am really hoping something will go wrong in that scenario) otherwise, I will still be confused about when to use the field reference…
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!