我是 PHP 和 WordPress 的新手,我想从头开始开发我的主题。
在 WordPress 仪表板上的阅读设置中,我已将首页显示选项设置为“您的最新帖子”,但主页是空白的,没有页眉或页脚,尽管其他页面都工作正常。
这是我的 index.php 代码:
<?php get_header(); ?>
<?php
if(have_posts()):
while(have_posts()): the_post(); ?>
<h3><?php the_title(); ?></h3>
<small>Posted on: <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?>, in <?php the_category(); ?></small>
<p><?php the_content(); ?></p>
<hr>
<?php endwhile;
endif;
?>
<?php get_footer(); ?>
谁能解释为什么会这样?
谢谢。
最佳答案
您可能正在加载另一个模板,它是一个空白文件。 WordPress 的模板层次结构在 https://developer.wordpress.org/themes/basics/template-hierarchy/#front-page-display 中列出。 . 对于您的情况,层次结构是 front-page.php、home.php、index.php,因此请检查前两个。
关于php - 首页显示(您的最新帖子)空白,其他页面正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40058328/