Advertisement
Guest User

WP Query Pagination

a guest
Aug 21st, 2014
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1. <?php
  2.     $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
  3.     $args = array(
  4.         'post_type' => 'post',
  5.         'posts_per_page' => '10',
  6.         'paged' => $paged,
  7.     );
  8.     $wp_query = new WP_Query($args);
  9. ?>
  10.  
  11. <?php while ($wp_query -> have_posts()) : $wp_query -> the_post(); ?>
  12.  
  13. <div id="title">
  14.     <li>
  15.         <a href="<?php the_permalink() ?>" class="title">
  16.             <?php the_title(); ?>
  17.         </a>
  18.         <div id="sub-title">
  19.  
  20.         <div id="date-post">
  21.             <img src="<?php bloginfo('template_directory'); ?>/img/date-icon.png" class="date-img" />
  22.             <p><?php echo get_the_date(); ?></p>
  23.         </div><!---Fim date-post--->
  24.  
  25.         <div id="tag-post">
  26.             <img src="<?php bloginfo('template_directory'); ?>/img/tag-icon.png" class="tag-img"/>
  27.             <p><?php the_tags('',', ',''); ?></p>
  28.         </div><!---Fim tag-post--->
  29.  
  30.         </div><!---Fim sub-title--->
  31.  
  32.     </li>
  33. </div>
  34.  
  35. <div id="thumbnail">
  36.     <?php the_post_thumbnail();?>
  37. </div>
  38.  
  39. <div id="thumbnail-bg">
  40. <div id="thumbnail-reflect">
  41. </div>
  42. </div>
  43.  
  44. <?php the_excerpt(); ?>
  45.  
  46. <div id="readmore">
  47.     <a href="<?php the_permalink() ?>" class="readmore">Continue Lendo</a>
  48. </div>
  49.  
  50. <div id="readmore-bg">
  51. </div>
  52.  
  53. <div id="break-line">
  54. </div>
  55.  
  56. <?php endwhile;?>
  57.  
  58. <?php
  59.     global $wp_query;
  60.     $big = 999999999; // need an unlikely integer
  61.     $translated = __( 'Page', 'mytextdomain' ); // Supply translatable string
  62.  
  63.     echo paginate_links( array(
  64.         'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
  65.         'format' => '?paged=%#%',
  66.         'current' => max( 1, get_query_var('paged') ),
  67.         'total' => $wp_query->max_num_pages,
  68.         'prev_text'    => __('«'),
  69.         'next_text'    => __('»'),
  70.  
  71.     ));
  72. ?>
  73. <?php wp_reset_postdata(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement