0
我刚刚创建了一个新的自定义页面模板并仅调用了两个帖子。 如何添加分页以便至少可以链接两个最新的帖子?如何将分页添加到我的自定义页面模板
我想这个代码,但它不工作:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(
array (
'post_type' => 'post',
'category_name' => 'news',
'category' => 1,
'posts_per_page' => 2,
'paged' => $paged)
);
// The Loop
while (have_posts()) : the_post();?>
<div class="news-page-content-wrapper">
<div class="news-page-content">
<h1><a class="read-more"href="<?php the_permalink(); ?>"><?php the_title();?></a></h1>
<figure><?php the_post_thumbnail(); ?></figure>
<p><?php echo get_the_excerpt();?></p>
<a href="<?php the_permalink(); ?>">Read More»</a>
</div>
</div>
<?endwhile;
// Reset Query
wp_reset_query();
?>
任何帮助吗?
我想这个代码,但它不工作,以及 <?php previous_posts_link(); ?> –
@SidneySousa以上的作品,我刚刚在我的一个测试网站上测试过。 – Daniel
不知道到底发生了什么不同,但我只是复制并粘贴了来自您发送的链接上的代码和代码。 –