您可以使用全局WP_Query
: max_num_pages
和paged
.
之后避免使用query_posts
对于新查询,请使用的新实例WP_Query
或get_posts
.
global $wp_query;
if ($wp_query->max_num_pages > 1 && $wp_query->get(\'paged\') < $wp_query->max_num_pages ) {
$next_page = (int)$wp_query->get(\'paged\') + 1;
?>
<div class="next-content">
<div class="page-header"><h3 class="article">Weiter <a href="<?php echo esc_url( home_url( \'/\' ) ); ?>page/<?php echo $next_page; ?>/" title="Zur Seite <?php echo $next_page; ?>">auf Seite <?php echo $next_page; ?></a> mit:</h3></div>
<?php
$post_num = $wp_query->get(\'posts_per_page\') ? : get_option(\'posts_per_page\');
$next_posts = get_posts(\'posts_per_page=\' . $post_num . \'&paged=\' . $next_page);
if ( ! empty($next_posts) ) {
echo \'<ul>\';
foreach( $next_posts as $next_post) {
?>
<li><a href="<?php echo get_permalink($next_post) ?>" rel="bookmark"><?php echo get_the_title($next_post); ?></a></li>
<?php
}
echo \'</ul>\';
}
?>
</div>
<?php
}