wp_pagenavi not working (solution)

2019-08-30 12:40发布

问题:

Had a minor problem with this neat plugin and solved it. It is said that wp_pagenavi does not work with eg. WP_query(). This should be also noted with get_posts(), did not see anything from this plugin. When changed to query_posts() then navi plugin started to work again.

回答1:

This form works:

 //if not exists assigns value 1
 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 

 //query 5 posts
 query_posts("posts_per_page=5&paged=$paged");