Public Service Announcement for ACF users…
Because of the new directory structure in Sage 9 and the way Sage informs WP by updating the ‘stylesheet’ option, Advanced Custom Fields looks for the acf-json
directory under /templates
rather than the theme root.
ACF doesn’t make it easy to determine where it’s looking so this took a bit of flailing to find out…
TLDR;
If using Sage 9, put acf-json
in the templates
directory.
5 Likes
Good find! I was curious why my latest project was not adding the acf json files… however since it was still early dev and everything was in the DB anyways, I figured ¯_(ツ)_/¯
It was driving me totally nuts - end of a long week!
ACF has a couple of filters for the save/load points, and the following puts things back to the usual acf-json location (or wherever):
<?php
// Set save point
add_filter('acf/settings/save_json', function ($path) {
$path = get_stylesheet_directory() . '/acf-json';
return $path;
});
// Set load point(s) - ACF loads all.json files from multiple load points
add_filter('acf/settings/load_json', function ($paths) {
// remove original path (optional)
unset($paths[0]);
// append path
$paths[] = get_stylesheet_directory() . '/acf-json';
return $paths;
});
7 Likes
For those using Sage Roots 9 Beta 3, the above code snippet is still needed. Make sure your acf-json
folder is in the resources
folder now.
5 Likes