Title: custom loop w/ customized first post
Last modified: August 20, 2016

---

# custom loop w/ customized first post

 *  [hirezolution](https://wordpress.org/support/users/hirezolution/)
 * (@hirezolution)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/custom-loop-w-customized-first-post/)
 * hey guys
 * im trying to set up a custom query on a static page to display the 5 most recent
   posts, with a customized first post (unique class and code).
 * the code i’ve come up with thus far takes care of customizing my first post, 
   but doesn’t define post count. i only want to display 5, i want to set a greater
   number for the actual blog page. make sense?
 * here’s what i’ve pieced together so far w/ minimal php expertise. any ideas?
 *     ```
       <?php if (have_posts()) : ?>
       <?php $post = $posts[0]; $c=0;?>
       <?php while (have_posts()) : the_post(); ?>
   
       <?php $c++;
       if( !$paged && $c == 1) :?>
       <li class="first post">
       <?php the_post_thumbnail(); ?>
       <h2><?php if (strlen($post->post_title) > 35) {
       echo substr(the_title($before = '', $after = '', FALSE), 0, 35) . '...'; } else {
       the_title();
       } ?></h2>
       <?php the_excerpt(); ?>
       </li>
   
       <?php else :?>
       <li class="post">
       <?php the_post_thumbnail(); ?>
       <h2><?php if (strlen($post->post_title) > 35) {
       echo substr(the_title($before = '', $after = '', FALSE), 0, 35) . '...'; } else {
       the_title();
       } ?></h2>
       <?php the_excerpt(); ?>
       </li>
       <?php endif;?>
   
       <?php endwhile; ?>
   
       <?php endif; ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/custom-loop-w-customized-first-post/#post-3154099)
 * You need to use [get_posts()](http://codex.wordpress.org/Template_Tags/get_posts)
   and define a ‘numberposts’ parameter. That will allow you to choose your post
   count for this loop only and set the site default to something else.

Viewing 1 replies (of 1 total)

The topic ‘custom loop w/ customized first post’ is closed to new replies.

## Tags

 * [loops](https://wordpress.org/support/topic-tag/loops/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/custom-loop-w-customized-first-post/#post-3154099)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
