Home › Forums › Add-ons › Flexible Content Field › Use PHP to add a field which can be managed in Admin? › Reply To: Use PHP to add a field which can be managed in Admin?
Ok could be moving in the right direction…
So I didn’t mention that this is using a parent / child theme relationship. I want the JSON to live in the parent theme and then for the child theme to read that JSON and add it to the admin.
I’ve tried adding a folder in my parent theme “acf-json-defaults”, and this code to my functions.php.
function my_acf_json_load_point( $paths ) {
// remove original path (optional)
unset($paths[0]);
// append path
$paths[] = get_template_directory_uri() . '/acf-json-defaults';
// return
return $paths;
}
add_filter('acf/settings/load_json', 'my_acf_json_load_point');
But it only seems to work if I put the “acf-json-defaults” folder in the child theme. Even then, when I save the field in admin, it creates a new JSON file with the same key in the “acf-json” folder.
Does that make sense??
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.