3

老实说,我还不了解 PHP。但是我想要实现的目标在我脑海中听起来很容易。

single.php这是我的 wordpress文件顶部的代码:

<?php get_header(); ?>

我创建了一个单独的标题,即header2.php.

我想知道我需要在single.php模板顶部写什么来调用header2.php而不是header.php

4

2 回答 2

5

如果你想要 header-2.php(而不是 header2.php),你必须调用:

<?php get_header('2'); ?>

请参阅此页面:http ://codex.wordpress.org/Function_Reference/get_header

于 2012-12-21T01:30:49.527 回答
3

只需创建一个头文件,如

header-myHeader2.php

并称它为

get_header('myHeader2');

语法是header-name.php,您可以使用该name部分调用。

在这里阅读更多

于 2012-12-21T01:30:23.873 回答