Support

Account

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??