昨天测试一款主题,在调用分页插件的时候,发现分页失效,即可以点分页页数,但显示的还是首页的内容。无论是分页插件,还是functions.php实现分页效果都没有效。网上搜了下,发现是query_posts的问题。顺便找了下解决的方法,博客吧简单介绍下解决分页失效的方法步骤。
WP分页失效的解决方法:
1 | <?php query_posts('showposts=9'); ?> |
1 2 3 4 5 6 | <?php $limit = get_option('posts_per_page'); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('&showposts=' . $limit=9 . '&paged=' . $paged); $wp_query->is_archive = true; $wp_query->is_home = false; ?> |
其中的limit后面的9是每页显示的文件数量
提示:不同的主题,query_posts部分的代码可能不相同。