-
-
Save blakemiller99/b3b0b6028a22734e281f3441ad2a69bc to your computer and use it in GitHub Desktop.
ACF 6.2 custom load and save paths for ACF JSON
This file contains 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[] = ABSBATH . '/wp-content/uploads/acf-json/post-types'; | |
$paths[] = ABSBATH . '/wp-content/uploads/acf-json/field-groups'; | |
$paths[] = ABSBATH . '/wp-content/uploads/acf-json/taxonomies'; | |
$paths[] = ABSBATH . '/wp-content/uploads/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 ABSBATH . '/wp-content/uploads/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 ABSBATH . '/wp-content/uploads/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 ABSBATH . '/wp-content/uploads/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 ABSBATH . '/wp-content/uploads/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