Nov27

WordPress query_posts 页码失效

wordpress

我希望在page-x.php输出某一分类文章,简单地想到query_posts,结果wp_pagenavi(); 失效,posts_nav_link();next_posts_link();都失效了。

后来咨询sola老师,她让我参考文档

http://codex.wordpress.org/Function_Reference/query_posts

最后我在文档找到了这个一篇

http://codex.wordpress.org/Pagination#Adding_the_.22paged.22_parameter_to_a_query

想翻译一下,但是有些懒啊,贴个代码吧。

$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
$args = array(
//彩蛋:以下三行实现WP-PostRatings评分插件评分由高到低排序,;)
‘meta_key’ => ‘ratings_average’,
‘orderby’ => ‘meta_value_num’,
‘order’ => ‘DESC’,
‘showposts’ => 10,
‘cat’=>79,
‘paged’ =>$paged
);
query_posts($args);

Comments are closed.