我正在尝试将我的帖子发布在另一个页面(博客)上,而我的“主页”页面显示为我的首页。这两个页面都分配了自己的模板(家庭主页,博客博客)。
在阅读设置中,我将首页设为主页,将帖子页面设为博客。但是当我访问url.com/blog时,它会显示与我的主页相同的模板。我不确定为什么它不会显示我的两篇博文。
在我的home.php模板中,我有以下代码,这可能是问题吗?
<!-- Display featured images -->
<?php
$args = array('post_type'=> 'page');
query_posts( $args );
?>
<!-- Get featured images -->
<div class="main-thumb left">
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
?>
<li>
<a href="<?php echo get_permalink(); ?>">
<div class="tint">
<div class="overlay caps">
<?php
echo(types_render_field("top-overlay", array("output"=>"html")));
?>
<?php
echo(types_render_field("bottom-overlay", array("output"=>"html")));
?>
</div> <!-- end .OVERLAY-->
<?php the_post_thumbnail(); ?>
</div> <!-- end .TINT-->
</a>
</li>
<?php
}
}
?>
</div> <!-- end .MAIN-THUMB-->
答案 0 :(得分:4)
home.php都将用作主页:
WordPress首先确定它是否有静态首页。如果已设置静态首页,则WordPress将根据页面模板层次结构加载该页面。
如果尚未设置静态首页,则WordPress会查找名为home.php的模板文件,并使用它来生成请求的页面。