• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Dev Tips / ACF database vs JSON Precedence

ACF database vs JSON Precedence

Last updated on July 17, 2019 by Sal Ferrarello

The WordPress Advanced Custom Fields plugin has support for defining Field Groups via a JSON file (in addition to the traditional way of defining the Field Group in the WP Admin screen, at /wp-admin/edit.php?post_type=acf-field-group). You can read about the ACF Local JSON feature in their documentation.

Database Vs JSON

One thing not clear to me in the documentation is what happens when you have two different definitions for a Field Group – one in the database and one in the JSON file.

JSON is Always Used

When both a database definition and a JSON definition are present, the JSON definition is always used – regardless of which one was modified most recently.

Sync Option

If the JSON was modified more recently than the database definition, you will have a Sync option in the WP Admin screen, which overwrites the database definition using the information from the JSON definition.

If the database definition was modified more recently than the JSON, you will NOT have a Sync option.

Database always displays on WP Admin Screen

Even when there is a JSON file present which defines the field group, if the field group also has a database definition the database definition will be displayed on the WP Admin screen where you would modify the field group. If you save (Update) the field group through the WP Admin screen, it will overwrite the JSON file with the information from the database definition.

Summary

Newest Definition Sync Used Shown in WP Admin
JSON available JSON Database
Database no JSON Database
Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Dev Tips, Draft Tagged With: Advanced Custom Fields, WordPress

Reader Interactions

Comments

  1. Sahil says

    June 29, 2022 at 12:48 pm

    This is interesting. I had to deal with losing ACF fields getting overwritten due to the lack of the above knowledge. Thank you so much for the information!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in