【问题标题】:can't solve :undefined function get_header()无法解决:undefined function get_header()
【发布时间】:2015-09-27 18:53:24
【问题描述】:

我正在尝试将静态 HTML 模板转换为 WordPress 模板。当我尝试加载index.php 时,我从header.php 收到以下错误:

致命错误:在第 1 行调用 C:\xampp\htdocs\site_name\wp-content\themes\template_name\features.php 中未定义的函数 get_header()

我已经搜索了解决方案,但没有找到。如果有人可以帮助我解决这个问题,我将不胜感激。

注:

  • 我没有修改我的根 index.php 文件
  • 我有最新版本的 WordPress 4.3.1
  • 我发现我使用的代码直接调用了一个文件(例如:features.php),这是我在 Wordpress 中无法做到的。如果是这种情况,谁能告诉我如何在不调用此直接调用的情况下调用文件。

这是我的header.php文件的代码:

<li><a href="<?php bloginfo('template_directory'); ?>/features.php">Features</a></li>

这是features.php 文件

<?php get_header(); ?>
<div class="container">
<div class="row signin_visitor_you">
<div class="row signin_visitor_you_top">
....

【问题讨论】:

  • 错误字面上告诉你哪里出了问题。在features.php 的第1 行,您正在调用未定义的函数get_header()get_header() 定义在哪里?
  • get_header() 是内置的 wordpress 函数。

标签: php wordpress header wordpress-theming


【解决方案1】:

wordpress 模板与静态 html 不同

你可以学习为初学者here创建wordpress模板

【讨论】:

    猜你喜欢
    • 2022-01-06
    • 2019-09-25
    • 1970-01-01
    • 1970-01-01
    • 2021-10-10
    • 1970-01-01
    • 2015-06-25
    • 1970-01-01
    • 2015-06-24
    相关资源
    最近更新 更多