Title: Make first post different
Last modified: August 19, 2016

---

# Make first post different

 *  [driz](https://wordpress.org/support/users/driz/)
 * (@driz)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/make-first-post-different/)
 * Hi, I have this code setup to grab my blog posts. I want to have my first post
   styled different (HTML and CSS). Would I need to create a new WP_Query? I want
   to have 100% flexibility, so I’m guessing this would be best option? Could someone
   please tell me how to do this. Thanks.
 *     ```
       <?php $blog_query = new WP_Query('category_name=blog&posts_per_page=5');
         while ($blog_query->have_posts()) : $blog_query->the_post();?>
   
       <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
   
       <h3><?php the_time('d/m/Y'); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
   
       <?php the_excerpt() ?>
   
       </div><!--post-->
   
       <?php endwhile; ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/make-first-post-different/#post-1301273)
 * > Would I need to create a new WP_Query?
 * Nope. eg:
 *     ```
       <?php $c = 0; $blog_query = new WP_Query('category_name=blog&posts_per_page=5');
       while ($blog_query->have_posts()) : $blog_query->the_post();?>
   
       <div <?php if( $c ==0 ) post_class('special'); else post_class() ?> id="post-<?php the_ID(); ?>">
   
       <h3><?php the_time('d/m/Y'); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
   
       <?php the_excerpt() ?>
   
       </div><!--post-->
       <?php $c++;?>
       <?php endwhile; ?>
       ```
   
 * You can then expand this to use `if( $c ==0 )` to output different markup etc.
   and use the class .special to style the first post differently to the rest.

Viewing 1 replies (of 1 total)

The topic ‘Make first post different’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/make-first-post-different/#post-1301273)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
