Custom Post Type Pagination on WordPress Static Homepage
Hi all today I am sharing the solution for fixing Custom Post Type Pagination on WordPress Static Homepage. I faced this issue when i used the Custom Post Type on WordPress Static Homepage the pagination was not working. Finally got the solution, use the following code for display Custom Post Type on WordPress Static Homepage with Pagination.
<?php if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } query_posts( array( 'post_type' => 'work','posts_per_page' => 4, 'paged' => $paged ) ); if ( have_posts() ) : $count = 0; while ( have_posts() ) : the_post(); $count++; ?> <div class="col-md-6 hbox"> <?php the_title(); ?> </div> <?php endwhile; else: ?> <div class="post"> <p><?php _e('Sorry, no posts matched your criteria.', 'woothemes') ?></p> </div><!-- /.post --> <?php endif; ?> <?php if(function_exists('wp_pagenavi')) { ?> <?php wp_pagenavi(); ?> <?php } else { ?> <div class="navigation"><p><?php posts_nav_link('∞','«« Previous Posts','Older Posts »»'); ?></p></div> <?php } ?> <?php wp_reset_query(); ?>