简体   繁体   English

WP Pagination 第二页不显示任何内容

[英]WP Pagination second page doesn't show anything

I'm creating a WP-Theme, but the Pagination-function doesn't work.我正在创建一个 WP 主题,但分页功能不起作用。 I see two buttons for Newer and Older, that works.我看到了两个新的和旧的按钮,这很有效。 But if I click on Older, I go to https://www.example.com/blog/page/2 , and that's completely white, without any posts.但是,如果我点击 Older,我会从 go 到https://www.example.com/blog/page/2 ,这完全是白色的,没有任何帖子。 Who can help me?谁能帮我? Thank you!谢谢!

Can you try this?你能试试这个吗?

  <?php
global $paged, $wp_query, $wp;
$args = wp_parse_args($wp->matched_query);
if ( !empty ( $args['paged'] ) && 0 == $paged ) {
$wp_query->set('paged', $args['paged']);
$paged = $args['paged'];
}
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('paged='.$paged.'&showposts=10&cat='.get_option('prototype_blog_cat'));
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<a href="<?php the_permalink(); ?>"> <?php the_title();
     ?></a>
 <?php endwhile; ?>
 <?php echo paginate_links( array(
  'prev_text' => '<span>Previous</span>',
  'next_text' => '<span>Next</span>'
)); ?>

It should work but if it fails do let me know.它应该可以工作,但如果失败,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM