我有一个带有wp_query的循环,代码如下:
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query("showposts=2&paged=$paged");
?>
<?php if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<?php the_title() ?>
<?php endwhile; ?>
<?php else: ?>
<article>
<h2><?php _e( 'Sorry, nothing to display.', 'theme' ); ?></h2>
</article>
<?php endif; my_pagination(); wp_reset_query()?>
Run Code Online (Sandbox Code Playgroud)
标准分页:
<?php
function my_pagination()
{
global $wp_query;
$big = 999999999;
echo paginate_links(array(
'base' => str_replace($big, '%#%', get_pagenum_link($big)),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'prev_text' => __('<i class="fa fa-chevron-left"></i>'),
'next_text' => __('<i class="fa fa-chevron-right"></i>'), …Run Code Online (Sandbox Code Playgroud)