Advertisement
Guest User

Untitled

a guest
Sep 7th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1. <?php
  2.  
  3. $paged = 1 ;
  4. if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); }
  5. if ( get_query_var( 'page' ) ) { $paged = get_query_var( 'page' ); }
  6. $paged = intval( $paged );
  7. $args = array( 'paged' => $paged  ) ;
  8.  
  9. $args = array(
  10.     'posts_per_page' => 9,
  11.         'paged' => $paged
  12. ) ;
  13. $my_query = new WP_Query($args) ;?>
  14.  
  15. <section id="" class="container-fluid">
  16.  
  17.     <?php $count = 0  ?>
  18.  
  19.     <?php if ($my_query->have_posts()) : ?>
  20.         <div class="row">
  21.             <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
  22.  
  23.                 <article class="post col col-xs-12 col-sm-4">
  24.                     <h3> <a href="<?php the_permalink()  ?>"><?php the_title()  ?></a></h3>
  25.                     <p><?php  the_excerpt(); ?></p>
  26.                     <?php  $count++ ?>
  27.                     <p><a href="<?php echo get_permalink()  ?>">read more</a></p>
  28.                 </article>
  29.                 <?php if ( $count %3 == 0  ) { ?>
  30.         </div>
  31.         <div class="row">
  32.                 <?php   }         ?>
  33.             <?php endwhile;  ?>
  34.     <?php endif; ?>
  35.  
  36. </section> <!-- ENDS .container  -->
  37.  
  38. <footer class="pagination container-fluid clearfix">
  39.     <div class="col col-xs-12">
  40.         <span>pages: </span>
  41.  
  42.     <?php
  43.     $big = 999999999;
  44.     $args = array(
  45.         'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
  46.         'format' => '?paged=%#%',
  47.         'current' => max( 1, get_query_var('paged') ),
  48.         'total' => $my_query->max_num_pages    
  49.     ) ;
  50.    
  51.     echo paginate_links( $args );   ?>
  52.  
  53.         <?php wp_reset_postdata()  ?>
  54.     </div>
  55. </footer>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement