Home › Forums › General Issues › Load fields from PHP exported file by default › Reply To: Load fields from PHP exported file by default
Here is my solution:
/*****************************************************************/
/* LOADING SWITCH FOR ACF FIELD GROUPS FROM PHP OR JSON FILE */
/*****************************************************************/
add_filter('acf/settings/load_json', function( $paths ) {
$dev_mode = get_field('mode_custom_fields_json', 'option');
// load basic [ MAIN THEME ] field groups from the [ MAIN THEME JSON ] folder
$paths = array( get_template_directory() . '/inc/acf-json' );
// load custom additional [ CHILD THEME ] field groups from the [ CHILD THEME JSON ] folder
if( is_child_theme() && $dev_mode ) {
$paths[] = get_stylesheet_directory() . '/acf-json';
}
// WITHOUT ACTIVATED DEV MODE --> load all fields from PHP file by the [ MAIN THEME ]
if( ! $dev_mode ) {
// load all field groups from PHP exported file for theme users
include_once( get_template_directory() . '/inc/acf-field-groups.php' );
}
return $paths;
});
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!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.