Last active
January 11, 2024 16:09
-
-
Save lgladdy/48863dfc593da85130e4140ce8fd35bc to your computer and use it in GitHub Desktop.
ACF 6.2 custom load and save paths for ACF JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'acf/json/load_paths', 'set_custom_json_load_paths' ); | |
function set_custom_json_load_paths( $paths ) { | |
$paths[] = get_stylesheet_directory() . '/acf-json/post-types'; | |
$paths[] = get_stylesheet_directory() . '/acf-json/field-groups'; | |
$paths[] = get_stylesheet_directory() . '/acf-json/taxonomies'; | |
$paths[] = get_stylesheet_directory() . '/acf-json/option-pages'; | |
return $paths; | |
} | |
add_filter( 'acf/settings/save_json/type=acf-post-type', 'set_custom_json_save_path_for_post_types' ); | |
function set_custom_json_save_path_for_post_types() { | |
return get_stylesheet_directory() . '/acf-json/post-types'; | |
} | |
add_filter( 'acf/settings/save_json/type=acf-field-group', 'set_custom_json_save_path_for_field_groups' ); | |
function set_custom_json_save_path_for_field_groups() { | |
return get_stylesheet_directory() . '/acf-json/field-groups'; | |
} | |
add_filter( 'acf/settings/save_json/type=acf-taxonomy', 'set_custom_json_save_path_for_taxonomies' ); | |
function set_custom_json_save_path_for_taxonomies() { | |
return get_stylesheet_directory() . '/acf-json/taxonomies'; | |
} | |
add_filter( 'acf/settings/save_json/type=acf-ui-options-page', 'set_custom_json_save_path_for_option_pages' ); | |
function set_custom_json_save_path_for_option_pages() { | |
return get_stylesheet_directory() . '/acf-json/option-pages'; | |
} | |
add_filter( | |
'acf/json/save_file_name', | |
function( $filename, $post, $load_path ) { | |
return empty( $load_path ) ? $filename : basename( $load_path ); | |
}, | |
10, | |
3 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment