Custom posts pagination based on all posts
-
I’ve managed to get the pagination working with custom posts working on my wordpress theme. I have only one problem left and i can’t find any solutions for it.
I have 9 posts I want to display (4 per page). So I should get 3 pages. Instead i get 12 pages. This is for 48 posts (which is the number of the total posts).
This is my code:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $loop = new WP_Query( array( 'post_type' => 'freemz_portfolio', 'posts_per_page' => 4, 'orderby'=> 'menu_order', 'paged'=>$paged, 'orderby'=> 'menu_order' ) ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <--- output code --> <?php endwhile; ?> <!-- page navi --> <div class="pagenavi"> <?php if(function_exists('wp_pagenavi')) { wp_pagenavi();} ?> </div> <!-- page navi end -->
When you check page 4, 5 etc. There is no result. The query is giving the correct results. But somehow the pagination is not based on the posts from the query.
Anyone got a bright idea?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom posts pagination based on all posts’ is closed to new replies.