The Magic of ACF Synchronized JSON
I love Advanced Custom Fields. It is an insanely helpful tool when it comes to custom theming. There is one trick that exists within it that I overlooked for way too long and it took someone pointing out its existence for me to realize it was there. Since then, I’ve tried to spread the word about its awesomeness. What I’m referring to is ACF Synchronized JSON.
Let’s rewind to before I knew this feature existed. If I created a new field group or similar in ACF and I needed to move it to another WordPress installation — let’s say I was working on a dev environment and didn’t want to fully resync the database, just needed to migrate the fields for a new feature — I might manually go and export the ACF field group then go in to the other install and upload the export file to import the field group there. If I was just adding a new field to an existing field group, I would sometimes just manually recreate it. Was I losing hours to this? No. Was it kind of annoying? Yes.
Enter ACF Synchronized JSON. (insert a heavenly chorus here)
Super simple to set up? Check.
If you have ACF Pro (120% worth it), it’s a matter of creating an acf-json folder within your theme. Drop an index.php file in there for some added security that just contains:
<?php // Silence is golden. ?>
Now, as you add new field groups, it will automatically create a JSON file and drop it into that folder for you. Learn more about local JSON ACF files by clicking here.
If you version control your themes with Git, which you should, your ACF field groups are also now able to easily be version controlled with the rest of your theme.
Want to sync it up to another install? Deploy the acf-json folder and its changes and you’ll see a “Sync Available” message when you go to Custom Fields > Field Groups on that install. Sync the fields and you’re good to go.
No more manual ACF exporting or ACF importing or repetition of tasks in this area. Version controlled ACF field groups. Magic.