Help with grid loop pagination
-
I’m using the following code to display a grid loop with the first post being a main post that’s styled differently than the rest. However, every paginated page follows the same format with the main post up top. What would I need to add to the code so all paginated pages just display the smaller post styling?
<?php if (have_posts()) : ?> <?php /* Custom loop to show n main posts (title + excerpt) then finish with remainder as small posts (just title) in markup that allows columns of unequal mini-posts in rows. Here one main post then subsequent mini-posts in rows of 3. Total number per page defined in WP options */ $count = 0; //start the counter $main_posts = 1; //set the number of main posts ?> <?php // find out how many posts so we can close this thing properly at the last post $totalposts = sizeof($posts); ?> <?php while (have_posts()) : the_post(); ?> <?php $count++; //increment counter by 1 ?> <?php $small_posts_count = ($count - $main_posts) ; // calculate the number of small posts ?> <?php if ($count < ($main_posts + 1)) : // if within the range of main post set above then... ?> <div <?php post_class('sheet') ?> id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <div class="entry"> <?php the_content('Read more') ; ?> </div> </div> <?php else : // if loop is at small_posts start a wrapper div.loop2 for next row of posts ?> <?php // if (count-1)/3 is an integer then it's first in the row: open the wrapper if (($small_posts_count - 1) % 3 == 0 ) { echo '<div class="loop2 clearfix">';} ?> <div class="sheet<?php if ((isset($small_posts_count)) && ($small_posts_count % 3 == 0 )) { echo ' last';} // same logic to add class of last to last item in row of three ?>" id="post-<?php the_ID(); ?>"> <h4><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4> </div> <?php //close the row if multiple of three (using same logic as above) or if it's the last post if (($count == $totalposts) || ($small_posts_count % 3 == 0 )) { echo '</div><!-- .loop2 -->';} // if is multiple of three ?> <?php endif; ?> <?php endwhile; ?> <?php if (!is_page()) { // get older and/or newer posts links (not for single posts) ?> <?php include( TEMPLATEPATH . '/tpl.nav.posts.php' ); ?> <?php ; } ?> <?php else : ?> <?php include( TEMPLATEPATH . '/tpl.search.404.php' ); // get 404 error message ?> <?php endif; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Help with grid loop pagination’ is closed to new replies.