Home › Forums › General Issues › Naming Conventions / Cleaning Up › Reply To: Naming Conventions / Cleaning Up
There is no perfect answer for this. Field naming is open to opinion.
When I am creating fields I try to prefix them all with something to ensure uniqueness, but this is also based on the conditions.
If I am building a plugin, the all field names have what I hope is a unique prefix.
If I’m building a site that will only be used for one client, then this usually does not happen. In this case, when it is appropriate, I use a prefix that matches what the fields are for. For example, if I am building a product sections then all the fields will be prefixed with something like product_ or prod_ if I want to keep it short.
Custom fields must be unique for the WP object they are attached to. All of the fields for a single Post must be unique. Any fields for a single Term must be unique. All Options fields must be unique. The exception to this are sub fields of any type. sub fields are automatically prefixed with the parent’s (and grandparent’s, all ancestors’) field name. This makes them unique if the top level parent field is unique.
As far as changing field names. There is no way to safely change a field name and update all of the fields in all locations with the new name. Changing field names will cause the data to become disconnected. This is no different than any standard WP meta_key.
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.