Posted By

Tate on 10/08/08


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

qubestream


Show different amount of posts on Wordpress home page than other pages


 / Published in: PHP
 

URL: http://pastebin.com/f318db5f3

  1. <?php
  2. // If we're on the index page, we only want the two first posts.
  3. if ( is_home() && !is_paged() )
  4. query_posts('posts_per_page=2');
  5.  
  6. // If we're within the index archives, we want ten posts per page as usual.
  7. else {
  8. // If we are past the second page, offset by an appropriate amount for the page.
  9. // I'm by no means a math guru; I don't know why this works. Trial & error rocks!
  10. if ( get_query_var('paged') != 2 )
  11. $offsetting = 2 + ( ( get_query_var('paged') - 2 ) * get_query_var('posts_per_page') );
  12.  
  13. // If we're on the second page, offset by two.
  14. else
  15. $offsetting = 2;
  16.  
  17. // Plug it into our query.
  18. query_posts($query_string . "&offset=$offsetting");
  19. }
  20. ?>

Report this snippet  

You need to login to post a comment.