当您使用WP_Query
要从数据库获取帖子,必须使用next_posts_link()
具有max_num_pages
当前查询的参数。
您可以按以下方式执行此操作。
<?php next_posts_link(\'More »\', $packages->max_num_pages) ?>
现在您的代码将变成这样。我在下面的代码中做了上述更改。
<div class="eight columns">
<ul>
<?php
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$packages = new WP_Query( array(
\'post_type\' => \'articles\',
\'posts_per_page\' => 2,
\'orderby\'=> \'menu_order\',
\'paged\' => $paged
));
if( $packages->have_posts() ) : while( $packages->have_posts() ) :
$packages->the_post();
?>
<li class="twelve columns">
<div class="articles">
<div class="contents">
<h2><?php the_title(); ?></h2>
<span><?php the_time(get_option(\'date_format\')); ?></span>
<div class="featured-image">
<?php if ( has_post_thumbnail()) { $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), \'large\'); echo \'<img src="\' . $large_image_url[0] . \'" title="\' . the_title_attribute(\'echo=0\') . \'" alt="\' . the_title_attribute(\'echo=0\') . \'">\'; } ?>
</div>
<p><?php the_excerpt(); ?></p>
</div>
</div>
</li>
<?php wp_reset_postdata(); ?>
<?php endwhile; else: ?>
<p><?php _e(\'Sorry, no posts matched your criteria.\'); ?></p>
<?php endif; ?>
<div class="alignleft"><?php previous_posts_link(\'« Previous\') ?></div>
<div class="alignright"><?php next_posts_link(\'More »\', $packages->max_num_pages) ?></div>
</ul>
</div>