最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How does a Genesis child theme understand that the Genesis theme is the parent theme?

programmeradmin1浏览0评论

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?

Share Improve this question asked Aug 21, 2019 at 10:07 mohitbmohitb 31 bronze badge 1
  • 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
Add a comment  | 

2 Answers 2

Reset to default 1

I'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.

发布评论

评论列表(0)

  1. 暂无评论