我有这段代码可以将博客中的所有帖子显示为每页 3 个(出于特定原因,我必须使用 Wp_Query)。我不知道如何为此添加分页。这是我的帖子列表代码:
<?php
$all_posts = new WP_Query(array(
'posts_per_page' => 3,
));
if ($all_posts->have_posts()): while ($all_posts->have_posts()) : $all_posts->the_post();
?>
<div class="row leftNestedRow whiteWrapper boxyShadow">
<div class="large-12 columns">
<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
}?>
<p class="authorDate">Av <a>Fryk</a>, <?php the_time('Y-m-d'); ?></p>
<p><span class="homepageBlogExerpt"><?php echo get_the_excerpt(); ?></span><a href="<?php the_permalink() ?>">[Läs mer]</a></p>
<ul class="tags">
<?php
$links = array();
foreach(get_the_tags() as $this_tag) {
if ($this_tag->name != "featured"){
$links[] = '<li><a href="'.get_tag_link($this_tag->term_id).'">'.$this_tag->name.'</a></li>';
}
}
$ai = 0;
while ($links[$ai]) {
echo $links[$ai];
$ai++;
}
?>
</ul>
</div>
</div>
<?php endwhile; ?>