这里我的帖子类型是“news\\u events”,每显示4篇帖子标题后就会显示分页。
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$news_events = array( \'post_type\' => \'news_events\', \'posts_per_page\' => 4, \'paged\' => $paged);
$wp_query = new WP_Query( $news_events );
if ( $wp_query->have_posts() ) : ?>
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post();?>
<?php the_title(); echo "<br/>"; ?>
<?php endwhile; ?>
<nav>
<?php previous_posts_link(\'« Newer\',$wp_query->max_num_pages); ?>
<?php next_posts_link(\'Older »\',$wp_query->max_num_pages); ?>
</nav>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( \'Sorry, no news events posts at this time.\', \'theme\' ); ?></p>
<?php endif; ?>