Title: Custom Loop Pagination
Last modified: August 21, 2016

---

# Custom Loop Pagination

 *  [pottrell](https://wordpress.org/support/users/pottrell/)
 * (@pottrell)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/custom-loop-pagination-3/)
 * Hi guys,
 * I’m trying to create a magazine style website. For this particular page I’d like
   to fetch the latest post and style it one way (style1). For all the other posts
   I’d like to just display smaller (style2).
 * This is working fine, BUT I would also like to enable pagination. Is there anyway
   to have pagination appear at the bottom, when the user clicks previous older 
   posts will be shown in the second style (style2)?
 * My code so far is below:
 *     ```
       <?php
       /*
       Template Name: Interview
       */
       get_header(); ?>
       <div id="content" class="wrapper">
   
       <div id="main" class="post">
       <ul id="latest-feature">
       <h3>Interviews</h3>
       <?php
           $args=array(
       	'cat' => '12,3',
       	'post_type' => 'post',
       	'post_status' => 'publish',
       	'posts_per_page' => 3,
       	'caller_get_posts'=> 1
       	);
   
       	$my_query = null;
       	$my_query = new WP_Query($args);
       	while ($my_query->have_posts()) : $my_query->the_post(); 
   
       	$counter++;
       	if($counter===1) {
       ?>
   
       <li class="main-box">
       <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
       <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'slider-image' );  } ?>
   
       <h4><?php the_title(); ?></h4></a>
       <span><?php the_time('j M') ?> | <?php comments_number('No Comments', 'One Comment', '% Comments' );?></span>
   
       <?php my_excerpt(40); ?>
   
       </li>
       </ul>
       <ul id="other-features">
       <?php } else { ?>
       <li class="box">
       <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
       <span class="box-img">
       <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'latest-thumb-small' );  } ?>
       </span>
       <div class="box-content">
       <h4>
       <?php the_title(); ?></a>
       </h4>
       <span><?php the_time('j M') ?> | <?php comments_number('No Comments', 'One Comment', '% Comments' );?></span>
       <?php my_excerpt(30); ?>
       </div>
       </li>
       <?php } ?>
   
       <?php endwhile; ?>
   
       <?php next_posts_link('« Older Entries', $my_query->max_num_pages) ?>
       <?php previous_posts_link('Newer Entries »') ?>
   
       </ul>
       </div>
       </div>
       <?php get_sidebar(); ?>
       </div>
       <?php get_footer(); ?>
       ```
   
 * TL;DR: Ideally I want to:
    Display the latest post as style1 Display all the 
   other posts as style2
 * When the user clicks NEXT/PREVIOUS, load more posts and style them as style2.
   Unless they are on the latest post page.

Viewing 1 replies (of 1 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/custom-loop-pagination-3/#post-4282817)
 * try and replace:
 *     ```
       $counter++;
       	if($counter===1)
       ```
   
 * with:
 * `if($my_query->current_post == 0 && !is_paged() )`

Viewing 1 replies (of 1 total)

The topic ‘Custom Loop Pagination’ is closed to new replies.

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [pagination](https://wordpress.org/support/topic-tag/pagination/)
 * [while](https://wordpress.org/support/topic-tag/while/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/custom-loop-pagination-3/#post-4282817)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
