Advertisement
Twansparant

Different post amounts shown per pagination page

Sep 5th, 2011
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.62 KB | None | 0 0
  1. <?php
  2.     $max_first_page = 3;  // Show this many posts on front page
  3.     $args = array(
  4.         'caller_get_posts' => 1, // Using stickies messes up the count0
  5.         'post_type' => 'news-item'
  6.     );
  7.     $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
  8.     $posts_per_page = 4;
  9.     $posts_to_skip = $posts_per_page - $max_first_page;
  10.    
  11.     if ($page == 1) {
  12.         $max_posts = $max_first_page;
  13.     } else {
  14.         $max_posts = $posts_per_page;
  15.         $args['offset'] = (($page - 1) * $max_posts)- $posts_to_skip;
  16.     }
  17.     $temp = $wp_query;
  18.     $wp_query= null;
  19.     $wp_query = new WP_Query($args);
  20.    
  21.     if ($wp_query->max_num_pages < ceil(($wp_query->found_posts + $posts_to_skip)/$posts_per_page))
  22.         ++$wp_query->max_num_pages;
  23.    
  24.     $counter = 0;
  25.     $style_classes = array('first','second');
  26.     $style_index = 0;
  27. ?>
  28.  
  29.      
  30. <?php if (have_posts()) : ?>
  31.     <?php while (have_posts()) : the_post(); ?>
  32.         <?php if (++$counter > $max_posts) continue; ?>            
  33.             <?php $c++; if(!$paged && $c == 1): // First post on first page ?>             
  34.                 <div class="most-recent-post">
  35.                                 // Large post
  36.                                 </div>
  37.  
  38.             <?php else: // All posts from first ?>         
  39.                 <div class="post-block <?php $k = $style_index%2; echo "$style_classes[$k]"; $style_index++; ?>">
  40.                 // Normal posts
  41.                 </div>         
  42.             <?php endif; ?>        
  43.     <?php endwhile; ?>
  44. <?php endif; ?>
  45.  
  46.  
  47. <!-- page nav -->
  48. <div class="page-navi">
  49.     <?php next_posts_link('Older Entries ยป', 0); ?>
  50.     <?php previous_posts_link('ยซ Newer Entries', 0); ?>
  51.     <?php if(function_exists('wp_paginate')) { wp_paginate(); } ?>
  52. </div>
  53. <?php $wp_query = null; $wp_query = $temp; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement