Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Read ACF fields from JSON
function PREFIX_acf_register_json_fields() {
if (function_exists("acf_add_local_field_group")) {
$acf_json_data = locate_template("path/to/advanced-custom-fields.json");
$custom_fields = $acf_json_data ? json_decode(file_get_contents($acf_json_data), true) : array();
foreach ($custom_fields as $custom_field) {
add_action("init", "PREFIX_acf_register_json_fields");

This comment has been minimized.

Copy link

@swinggraphics swinggraphics commented Jan 24, 2020

For anyone looking to do the same thing, except make the fields editable, change acf_add_local_field_group to acf_import_field_group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment