Posted By

kristarella on 03/21/10


Tagged

wordpress wp thesis thesiswp


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

naeemnur


Display extra posts on pages following home


 / Published in: PHP
 

URL: http://diythemes.com/forums/showthread.php?p=119036

This is designed to show 10 posts on each of the pages after the home/blog page when the home page only shows 5 (because if you just use postsperpage=10 without the offset you will lose the most recent posts numbered 6-10 in between the first and secon home/blog paged).

You can tweak it to different numbers, but you'll need to change the maths (10 * ($page - 1) - 5) to suit.

  1. function custom_queries() {
  2. global $query_string;
  3. if (is_home()) {
  4. $page = get_query_var('paged');
  5. if ($page > 1 )
  6. $offset = 10 * ($page - 1) - 5;
  7. else
  8. $offset = 0;
  9. if ($page > 1 )
  10. query_posts($query_string . "&posts_per_page=10&offset=$offset");
  11. }
  12. }
  13. add_action('thesis_hook_before_content', 'custom_queries');

Report this snippet  

You need to login to post a comment.