【发布时间】:2017-12-19 16:22:34
【问题描述】:
我正在创建一个自定义 WordPress 主题,更具体地说是 index.php 文件。当我导航到我的网站主页时,标题显示正确,但偶尔会在服务器日志中显示错误:
PHP Fatal error: Uncaught Error: Call to undefined function get_header() in D:\home\site\wwwroot\wp-content\themes\OryTheme\index.php:1
Stack trace:
#0 {main}
thrown in D:\home\site\wwwroot\wp-content\themes\OryTheme\index.php on line 1
我不知道为什么它显示标题时会出错。此外,如果我删除 <?php get_header(); ?>,标题将不会显示。我可以忽略这些错误吗?
index.php
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
<h1><?php the_title(); ?></h1>
<h4>Posted on <?php the_time('F jS, Y') ?></h4>
<p><?php the_content(__('(more...)')); ?></p>
</div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
【问题讨论】:
标签: php html wordpress wordpress-theming