In most Genesis child themes, the following line of code exists:
// Starts the engine.
require_once get_template_directory() . '/lib/init.php';
I understand that this includes the init.php file from the lib directory within the Genesis parent theme folder.
My question is simply - why does get_template_directory()
return the Genesis parent folder, as opposed to the child theme folder? And how does it identify it if there are multiple parent themes possible?
In most Genesis child themes, the following line of code exists:
// Starts the engine.
require_once get_template_directory() . '/lib/init.php';
I understand that this includes the init.php file from the lib directory within the Genesis parent theme folder.
My question is simply - why does get_template_directory()
return the Genesis parent folder, as opposed to the child theme folder? And how does it identify it if there are multiple parent themes possible?
- Is there any reason you think it's anything other than the way any other child theme works? developer.wordpress/themes/advanced-topics/child-themes – Jacob Peattie Commented Aug 21, 2019 at 10:09
2 Answers
Reset to default 1I'm not experienced with Genesis, specifically, but I imagine its child themes work the same as child themes for any other theme. As documented, a child theme is created by adding a Template:
line to the style.css header, which is the directory name of the parent theme:
/*
Theme Name: Genesis Child Theme
Template: genesis
*/
By defining the "Template" for a theme, WordPress functions like get_template_directory()
know to use that theme's directory for the path or URL.
There is no multiple parent theme possible. Because you specify parent theme by Template: genesis. This helps WordPress to find parent theme.