php - How i can enable WordPress Posts Pagination -


how can enable pagination in page (template page wordpress)

my code

<?php $catquery = new wp_query( 'cat=2&posts_per_page=10' ); while($catquery->have_posts()) : $catquery->the_post(); ?> <div>   <br /> <div class="news"><!-- start news box --> <div class="img_news"><!-- start image news --> <?php $url_thumb = wp_get_attachment_url( get_post_thumbnail_id($post->id) ); ?> <img class="img_thumbs" title="" alt="" src="<?php echo $url_thumb; ?>"> </div><!-- end image news --> <div class="title_news"><!-- start title news --> <h2> <?php the_title(); ?> </h2> <div class="details"> <?php the_content_limit(500, "read more..."); ?> </div> </div><!-- end title news --> <hr> </div><!-- end news box --> </div> <?php endwhile; ?> 

i using can't see pagination bar : example (1-2-3-...-100)

thanks

you need add 'paged' attribute in argument($catquery).

$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1; $catargs = array('cat'=>'2','posts_per_page'=>10,'paged' => $paged);  $catquery = new wp_query( $catargs); while($catquery->have_posts()) : $catquery->the_post(); //do stuff endwhile;  $big = 999999999;  echo paginate_links( array(     'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),     'format' => '?paged=%#%',     'current' => max( 1, get_query_var('paged') ),     'total' => $catquery->max_num_pages,     'prev_text'          => __( 'previous page', 'twentyfifteen' ),     'next_text'          => __( 'next page', 'twentyfifteen' ), ) );  

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -