As per the instructions in functions.php, you would need to put your ACF folder in /resources/, not the theme root. Sage9 modifies calls to get_stylesheet_directory() to point at that subdirectory, which may be causing ACF to not load.
then I added the following filters to my filters.php file and included the path to the ACF main file:
/**
* Customize ACF path
*/
add_filter('acf/settings/path', function ( $path ) {
$path = get_stylesheet_directory() . '/../vendor/advanced-custom-fields/advanced-custom-fields-pro/';
return $path;
});
/**
* Customize ACF dir
*/
add_filter('acf/settings/dir', function ( $dir ) {
$dir = get_stylesheet_directory_uri() . '/../vendor/advanced-custom-fields/advanced-custom-fields-pro/';
return $dir;
});
/**
* Hide ACF field group menu item
*/
// add_filter('acf/settings/show_admin', '__return_false');
/**
* include ACF
*/
include_once( get_stylesheet_directory() . '/../vendor/advanced-custom-fields/advanced-custom-fields-pro/acf.php' );
to submit your ACF Pro key just create an .env file in your theme directory and put it there:
ACF_PRO_KEY=PASTE_YOUR_ACF_PRO_KEY_HERE
now run composer update and you are good to go.
I also recommend creating a folder named acf-json in your resources folder. The plugin will then automatically detect it and save your field groups in json format. Find it in the ACF documentation
First of all, thanks to all the Roots team for the amazing Sage 9 theme (and for the Roots suite!), I’m new to it but I already see how it will help me develop and maintain WordPress themes.
My problem is that when I run composer install the advanced-custom-fields folder gets installed in the vendor directory but there is no ACF plugin listed in the Plugins page of the WordPress admin.
Is there a step I’m missing? I run the exact same code as @janman22 except for the filters.php file that is not referenced in the official plugin documentation. Also in my case the ACF pro version is 5.6.9
Well, I finally managed to solve my problem. I don’t really understand what went wrong with my first tries, so in case it could be useful for someone, here is a gist with the modified bedrock composer.json to install ACF Pro 5.6.9 in a Bedrock/Sage configuration.
The easiest way to include ACF is imply to unzip the plugin in to your /resources/ folder and rename it to just “acf”. Then put the following in to your setup.php file at the bottom: