Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Set Max Posts with WP Pagination

By: a guest on May 10th, 2012  |  syntax: PHP  |  size: 0.64 KB  |  views: 156  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. $temp = $wp_query;
  3. $wp_query= null;
  4. $wp_query = new WP_Query();
  5. $wp_query = new WP_Query( array(
  6. 'post_type' => 'posts',
  7. 'category' => 'your category'
  8. 'posts_per_page'=> 10,
  9. 'orderby'=> 'menu_order', //this comes in handy later!
  10. 'order'=> 'ASC',
  11. 'paged'=>$paged,
  12. ));?>
  13.  
  14. <?php while ($wp_query->have_posts()) : $wp_query->the_post();?>
  15. <div class="entry"> <!--or whatever div you want your posts to go in -->
  16. <?php $postNum = $post->menu_order + 1; if ($postNum < 31) : ?>
  17. <!--back to the post-->
  18. <?php else : wp_reset_query(); ?> <!--This is what stops the query after the 30th post!-->
  19. <?php ; endif; ?>
  20. </div>
  21. <?php endwhile;?>