Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* 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) {
acf_add_local_field_group($custom_field);
}
}
}
add_action("init", "PREFIX_acf_register_json_fields");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.