php - pagination in custom post type issue -
i faced weird issue. make post type "insight" , want pagination (no plugin). when click on next post shows me 404 error
here code
<?php if ( get_query_var('paged') ){ $paged = get_query_var('paged'); } else { $paged = 1; } query_posts(array('post_type'=>'insight','posts_per_page'=>'1','order'=>'desc', 'paged' => $paged)); ?> <?php while (have_posts()) : the_post(); ?> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« new entries') ?></div> <div class="alignright"><?php previous_posts_link('« older entries') ?></div> </div>
i don't no why happen because think code right.
foy blog use this:
functions.php:
if ( ! function_exists( 'my_pagination' ) ) : function my_pagination() { global $wp_query; $big = 999999999; // need unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $wp_query->max_num_pages ) ); } endif;
and after endwhile, in page want use pagination categories, index etc... use:
<?php endwhile; ?> <?php my_pagination(); ?>
i hope helps if try :)
edit - see in action visit: http://ios-blog.co.uk
Comments
Post a Comment