我有一个页面,我只想每页显示一篇文章,底部有分页,以便转到下一篇/上一篇文章。这是我的代码:
<?php $paged = ( get_query_var( \'paged\' ) ) ? get_query_var( \'paged\' ) : \'1\';
$args = array (
\'nopaging\' => false,
\'paged\' => $paged,
\'posts_per_page\' => \'1\',
\'post_type\' => \'post\',
\'category_name\' => \'enforcement\',
);
?>
<?php
$wp_query = new WP_Query($args);
?>
<?php if ( $wp_query->have_posts() ) : ?>
<?php while ( $wp_query->have_posts() ) : the_post(); ?>
<!--<div class="case-studies-text-banner">
<img src="http://www.mariadev.co.uk/wp-content/uploads/2017/05/case-study-layer.png"/>
<div class="case-study-title"><?php the_title(); ?></div>
<div class="case-study-pdf"><?php if (function_exists("wpptopdfenh_display_icon")) echo wpptopdfenh_display_icon();?></div>
</div>-->
<?php the_content(); ?>
<?php endwhile; ?>
<?php next_posts_link( \'Older Entries »\', $query->max_num_pages ); ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php __(\'No News\'); ?></p>
<?php endif; ?>
它在第一页上只显示1篇文章,但当单击旧文章并移动到此url时
www.testing./?cat=8&paged=2
即使此类别中有3个帖子,也不会显示任何帖子。知道我做错了什么吗?