Advertisement
Guest User

WordPress Post Query

a guest
Sep 14th, 2013
73
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     <section id="content" class="primary" role="main">
  2.        
  3.     <?php // Get Paged Variable
  4.         if ( get_query_var('paged') )
  5.             $paged = (int)get_query_var('paged');
  6.         elseif ( get_query_var('page') )
  7.             $paged = (int)get_query_var('page');
  8.         else
  9.             $paged = 1;
  10.        
  11.         // Query Posts
  12.         global $more;
  13.         $query_arguments = array(
  14.                 'post_type' => 'post',
  15.                 'posts_per_page' => '10',
  16.                 'paged' => $paged
  17.             );
  18.         $new_query = new WP_Query($query_arguments);
  19.        
  20.         if ($new_query->have_posts()) : while ($new_query->have_posts()) : $new_query->the_post();
  21.    
  22.             $more = 0;
  23.             get_template_part( 'loop', 'content' );
  24.        
  25.             endwhile;
  26.  
  27.         endif;
  28.        
  29.     ?>
  30.        
  31.         <div class="navigation">
  32.             <div class="next-posts"><?php next_posts_link('&laquo; Older Entries', $new_query->max_num_pages) ?></div>
  33.             <div class="prev-posts"><?php previous_posts_link('Newer Entries &raquo;', $new_query->max_num_pages) ?></div>
  34.         </div>
  35.            
  36.     </section>
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement