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
不知道到底發生了什麼不同,但我只是複製並粘貼了來自您發送的鏈接上的代碼和代碼。 –