【发布时间】:2014-06-27 12:24:16
【问题描述】:
所以我正在构建一个 WP One Page 主题,我希望每个页面都显示在我的静态首页上。我希望用户能够在仪表板中添加/编辑页面内容而不是标记。当我查看页面模板时,the_content() 工作正常,但是当我在静态首页上需要页面模板时,其他所有内容都正常显示,但 the_content() 为空白。有任何想法吗??谢谢!
work.php 文件
// Work Template Page -- the_content() works perfectly
<!-- works -->
<section id="works">
<!-- container -->
<div class="container">
<!-- row -->
<div class="row">
<!-- head -->
<div class="head big wow bounceIn">
<h3>Our
<span class="blue">Works</span>
</h3>
<div class="head-break-line">
<span class="head-line-blue"></span>
</div>
<?php if ( have_posts() ) : while( have_posts() ) : the_post(); ?>
<h6 class="subtext"><?php the_content(); ?></h6>
<?php endwhile; endif; ?>
</div>
front-page.php 文件
// Static Front-Page -- every thing works, but the_content() is blank on this page
<?php require('work.php'); ?>
【问题讨论】:
-
你确定页面有任何内容吗?您可以尝试使用
<?php global $post; var_dump($post); ?>输出当前帖子,以查看当时是否已将范围设置为您的帖子。 -
谢谢我昨天误会了你。你是对的。该职位超出了范围。由于我使用front-page.php 作为我的静态和home.php 作为我的帖子,当需要work.php 文件到我的front-page.php 时,我的post 变量设置为'home'。显然,我还有很多学习要做。如何更改范围以匹配 work.php 文件中的帖子?谢谢!