get_header() 如何调用特定的 PHP 文件?

Aki*_*n A 2 php wordpress include get-headers

我正在尝试通过研究一些免费插件/主题来学习 WordPress 结构。

我现在正在研究“Renger博客主题”,但我无法理解一些东西。我已经检查了WP 手册中的get_header () 页面,但它看起来仍然很神奇:)

该主题有自定义功能代码

wordpress\wp-content\themes\renderblog\inc\renderoption.php 
Run Code Online (Sandbox Code Playgroud)

这个主题只用调用这个文件

get_header();
Run Code Online (Sandbox Code Playgroud)

在index.php中

header.php中没有包含代码。

它是如何调用这个特定的 PHP 文件的get_header()?这是否是一种自动包含 inc 文件夹中所有文件的方法?

当我刚刚get_header()从index.php 中删除时,这些功能不起作用。

Inf*_*nic 5

WordPressget_header()是WordPress内置结构预定义的功能。此功能包括主题的标题模板,或者如果指定了名称,则将包括专门的标题。

如果文件名为“header-new.php”,则指定“new”。

例如<?php get_header('new'); ?>

不同页面的不同标题的另一个示例。

<?php
// if detect home page of wordpress
if ( is_home() ) :
    get_header( 'home' );
// if detect Not found page 404 of wordpress
elseif ( is_404() ) :
    get_header( '404' );
// default header if nothing specific is detected
else :
    get_header();
endif;
?>
Run Code Online (Sandbox Code Playgroud)