Include Advanced Custom Fields or Advanced Custom Fields Pro in your theme and save fields groups as json (pretty awesome). This will allow you to easily version control fields and fieldgroups in GIT. Just move the plugin to your theme folder, rename it to “acf” and create another folder called “acf-fields”. Paste this to your functions.php.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
// Set the path add_filter('acf/settings/path', 'my_acf_settings_path'); function my_acf_settings_path( $path ) { $path = get_stylesheet_directory() . '/acf/'; return $path; } // Set the directory add_filter('acf/settings/dir', 'my_acf_settings_dir'); function my_acf_settings_dir( $dir ) { $dir = get_stylesheet_directory_uri() . '/acf/'; return $dir; } // uncomment this to hide the menu in wp-admin //add_filter('acf/settings/show_admin', '__return_false'); // Include acf in your theme include_once( get_stylesheet_directory() . '/acf/acf.php' ); // Save fields groups to file add_filter('acf/settings/save_json', 'my_acf_json_save_point'); function my_acf_json_save_point( $path ) { $path = get_stylesheet_directory() . '/acf-fields/'; // this folder needs to be created first return $path; } // Load field groups from file add_filter('acf/settings/load_json', 'my_acf_json_load_point'); function my_acf_json_load_point( $paths ) { unset($paths[0]); $paths[] = get_stylesheet_directory() . '/acf-fields/'; // this folder needs to be created first return $paths; } |