Skip to content

Instantly share code, notes, and snippets.

@lgladdy
Last active January 11, 2024 16:09
Show Gist options
  • Save lgladdy/48863dfc593da85130e4140ce8fd35bc to your computer and use it in GitHub Desktop.
Save lgladdy/48863dfc593da85130e4140ce8fd35bc to your computer and use it in GitHub Desktop.

Revisions

  1. lgladdy revised this gist Aug 8, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions custom-acf-json-paths.php
    Original file line number Diff line number Diff line change
    @@ -11,11 +11,11 @@ function set_custom_json_load_paths( $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';
    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';
    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() {
  2. lgladdy created this gist Aug 8, 2023.
    36 changes: 36 additions & 0 deletions custom-acf-json-paths.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    <?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
    );