How to use pagination in wp_query in wordpress ?
Use pagination in wp_query in wordpress
Best Way of getting pagination in wp_query is –
<?php $paged = get_query_var('paged'); $args = array( 'cat' => 1, 'posts_per_page' => 5, 'paged' => $paged, ); $bolly_post = new WP_Query($args); if ( $bolly_post->have_posts() ) : while ( $bolly_post->have_posts() ) : $bolly_post->the_post(); ?> <a href="<?php echo get_the_permalink(get_the_ID())?>"><?php echo the_post_thumbnail()?></a> <p class="p-title"><a href="<?php echo get_the_permalink(get_the_ID())?>"><?php the_title(); echo " | Uploded By:" . get_the_author();?></a> <?php endwhile; ?> <div class="row mp pagination" style="margin-top:20px;" > <?php echo paginate_links(array( 'total' => $bolly_post->max_num_pages ) ); ?> </div>
OR you can use another way by using WP-PageNavi plugin
/* just install and active the plugin and then paste this code in place of above one */ <div class="row mp pagination" style="margin-top:20px;" > <?php wp_pagenavi( array( 'query' => $bolly_post, ) ); ?> </div>
POST COMMENTS