以下代码将在我的博客模板的主页或首页上显示单个帖子(最近发布的帖子),我想删除单个帖子(最近的帖子)并将其替换为一些文字,从第2页开始说“旧帖子” .
当用户点击第2页时,条件 is_home() 返回true的问题,因为从逻辑上讲它是主页上的查询请求 . 所以我尝试用 is_page(1) 替换 is_home() 并且也累了 is_front_page() 但没有结果
Here你可以看到工作代码 .
<? if(is_home()) : ?>
<div>
<h3>Recent Post</h3>
<? query_posts('posts_per_page=1');
while(have_posts()):the_post();?>
// iteration code here
<!-- End Single Post -->
<?php endwhile;wp_reset_query();?>
</div> <!-- if condition ends-->
<? else : ?>
<div>
<h3>Older Post</h3>
</div>
<? endif;?>
1 回答
用
(is_paged())
替换(is_home())
解决了这个问题 .