我已经从Wordpress文档中复制了有关使用将分页添加到自定义查询的代码\'paged\' => $paged
. 然而,在我的页面上,它不起作用。我做错了什么??
<?php
$paged = ( get_query_var( \'paged\' ) ) ? get_query_var( \'paged\' ) : 1;
$args = array(\'post_type\' => \'post\', \'posts_per_page\' => 10, \'paged\' => $paged);
$the_query = new WP_query($args);
if ( $the_query->have_posts() ) : ?>
<ul class="pis-ul">
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li class="pis-li">
<a class="pis-title-link" href="<?php echo the_permalink(); ?>">
<div class="news-thumbnail">
<?php
if(has_post_thumbnail()) {
echo the_post_thumbnail(\'news-thumbnail\');
}
?>
</div>
<p class="pis-title">
<?php the_title(); ?>
</p>
<p class="pis-excerpt">
<?php the_excerpt(); ?>
</p>
<p class="pis-utlility">
<span class="pis-date">Published on <?php echo the_date(); ?></span>
</p>
</a>
</li>
<?php endwhile; ?>
<ul>
<div class="nav-previous alignleft"><?php next_posts_link( \'Older posts\' ); ?></div>
<div class="nav-next alignright"><?php previous_posts_link( \'Newer posts\' ); ?></div>
<?php else: ?>
<p>
<?php _e(\'Sorry, this page does not exist.\'); ?>
</p>
<?php endif; ?>