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

问题描述 投票:1回答:1

我正在尝试研究一些免费的插件/主题来学习Wordpress Structure。

我正在研究“ Renger Blog主题”,但我听不懂。我已经检查了WP手册中的get_header()页面,但它仍然看起来像是魔术:)

此主题具有自定义功能代码

wordpress\wp-content\themes\renderblog\inc\renderoption.php 

并且此主题仅用此名称调用此文件

get_header();

in index.php

[中或其他地方没有包含代码。

如何使用get_header()调用此特定的PHP文件?这是一种自动将所有文件包含在inc文件夹中的方法吗?

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

php wordpress include get-headers
1个回答
0
投票
WordPress get_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; ?>

© www.soinside.com 2019 - 2024. All rights reserved.