Home › Forums › General Issues › Problem with theme Child Creation
Hi guys, i have a big problem with ACF.
When I try to integrate the plugin into my theme, follow these steps:
http://www.advancedcustomfields.com/resources/including-acf-in-a-plugin-theme/
All is well.
If you try to create a child theme to override some functions in my parent theme I get this error:
Warning: include_once(/home/yzjynndy/public_html/wp-content/themes/rabbitstudio/inc/extension/option-builder/acf.php): failed to open stream: No such file or directory in /home/yzjynndy/public_html/wp-content/themes/themerabbit/functions.php on line 20
Warning: include_once(): Failed opening '/home/yzjynndy/public_html/wp-content/themes/rabbitstudio/inc/extension/option-builder/acf.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/yzjynndy/public_html/wp-content/themes/themerabbit/functions.php on line 20
Fatal error: Call to undefined function get_field() in /home/yzjynndy/public_html/wp-content/themes/themerabbit/inc/theme-option.php on line 39
The problem seems to be due to the use of:
get_stylesheet_directory
rather than
get_template_directory
But if you use the latter ACF does not render well fields and no longer work.
Any suggestions to help me with this problem?
Ok, I have find a solution 😀
This is the code (file functions.php theme master) that you must use if you want to include in a theme acf and expect the opportunity to create a child theme:
/*ACF*/
// 1. customize ACF path
add_filter('acf/settings/path', 'my_acf_settings_path');
function my_acf_settings_path( $path ) {
$path = get_template_directory() . '/acf/';
return $path;
}
// 2. customize ACF dir
add_filter('acf/settings/dir', 'my_acf_settings_dir');
function my_acf_settings_dir( $dir ) {
$dir = get_template_directory_uri() . '/acf/';
return $dir;
}
// 3. Hide ACF field group menu item
if ( ! has_filter( 'acf/settings/show_admin' ) ) {
add_filter('acf/settings/show_admin', '__return_false');
}
// 4. Include ACF
include_once( get_template_directory() . '/acf/acf.php' );
If you want to show the Options menu ACF in child theme, use the following filter (file functions.php theme child):
add_filter('acf/settings/show_admin', '__return_true');
I hope this can be helpful as it was for me 🙂
The topic ‘Problem with theme Child Creation’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.