Title: Different posts styles
Last modified: August 20, 2016

---

# Different posts styles

 *  [aivaras2](https://wordpress.org/support/users/aivaras2/)
 * (@aivaras2)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/different-posts-styles/)
 * Hello, guys im looking for help.
    Leet say i have posted 10 posts and i need 
   that first post would have different style then counts posts till 4 and set another
   style to posts. Then resets and do same think till next page. <div class=’posts-
   first’>content</div> <div class=’posts’>content</div> <div class=’posts’>content
   </div> <div class=’posts-last’>content</div> then resets and do <div class=’posts-
   first’>content</div> <div class=’posts’>content</div> <div class=’posts’>content
   </div> <div class=’posts-last’>content</div>
 *     ```
       <?php get_header();  ?><?php
       /*
       Template Name: Blog of joeybottle
       */
       $pagenum = $wp_query->query_vars;
       $pagenum = $pagenum['paged'];
   
       if (empty($pagenum)) {
       $pagenum = 1;
       }
   
       query_posts("paged=$pagenum");
       ?>
   
       <?php get_header();?>
   
       <?php if (have_posts()) :$count = 0; ?>
   
       <?php while (have_posts()) : the_post(); ?>
   
       <div class="<?php if($counter==0) { echo 'first'; $counter++; } ?> post">
   
       <a href="<?php the_permalink() ?>"><?php the_title() ?></a>
   
       </div>
   
       <?php endwhile; ?>
   
       <div class="navigation">
       <div class="alignleft"><?php next_posts_link(__('&laquo; Older Entries', 'joeybottle')) ?></div>
       <div class="alignright"><?php previous_posts_link(__('Newer Entries &raquo;', 'joeybottle')) ?></div>
       </div>
   
       <?php endif; ?>
   
       <?php get_footer(); ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/different-posts-styles/#post-3345694)
 * Try changing this:
 *     ```
       <?php while (have_posts()) : the_post(); ?>
   
       <div class="<?php if($counter==0) { echo 'first'; $counter++; } ?> post">
       ```
   
 * to this:
 *     ```
       <?php while (have_posts()) : the_post();
       $class = ($counter++ == 0) ? 'first-post' : (($counter > 3) ? 'last-post' : 'post');
   
       <div class="<?php echo $class; ?>">
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Different posts styles’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/different-posts-styles/#post-3345694)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
