Title: Post highlighting solutiuons
Last modified: February 25, 2018

---

# Post highlighting solutiuons

 *  [keneso](https://wordpress.org/support/users/keneso/)
 * (@keneso)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/which-solution-is-better/)
 * Hi
    I am trying to make my custo theme, and looking for last post highlight, 
   by searching I found two solutions, and would like to know which one is better.
   For both I am using them in the index file.
 * Solution A
 *     ```
       <?php
       while( have_posts() ): the_post();
       if($i==0): $column_xs = 12; $column_sm = 12; $class = ' fz-recent-post';
       elseif($i > 0 && $i <= 2): $column_xs = 12; $column_sm = 6; $class = ' fz-old-posts';
       elseif($i > 2): $column = 4; $class = ' third-row-padding';
       endif;
       ?>
       	<div class="col-xs-<?php echo $column_xs; ?> col-sm-<?php echo $column_sm; echo $class; ?> extra-class">
       	Post info (i.e. title, excerpt)
       	</div>
       <?php $i++; endwhile; ?>
       ```
   
 * Solution B
 *     ```
       <?php
       $args = array(
       	'post_type' => 'post',
       	'posts_per_page' => 1
       );
       $query = new WP_query ( $args );
       if ( $query->have_posts() ) { 
       while ( $query->have_posts() ) : $query->the_post(); ?>
       	<div class="row">
       	Post info (i.e. title, excerpt)
       	</div>
       <?php endwhile;
       wp_reset_postdata(); ?>
   
       <?php
       $args = array(
       	'post_type' => 'post',
       	'offset' => 1
       );
       $query = new WP_query ( $args );
       if ( $query->have_posts() ) { 
       while ( $query->have_posts() ) : $query->the_post(); ?>
       	<div class="row">
       	Post info (i.e. title, excerpt)
       	</div>
       <?php endwhile;
       wp_reset_postdata(); 
       } ?>
       ```
   
 * Thank you

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [danieltj](https://wordpress.org/support/users/danieltj/)
 * (@danieltj)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/which-solution-is-better/#post-10011287)
 * I haven’t checked the code works, I’m assuming it does – but from a quick glance
   I would say the first option is better because the second option creates two 
   loops when you only need to loop through the posts once. Better load time/performance.
 *  Thread Starter [keneso](https://wordpress.org/support/users/keneso/)
 * (@keneso)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/which-solution-is-better/#post-10011656)
 * Thank you.
    I thought so, but confirmation from who knows better is always good.
 * Yes they both work, with my knowledge the second allows more layout flexibility,
   but I guess I’ll opt for performance.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Post highlighting solutiuons’ is closed to new replies.

## Tags

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

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [keneso](https://wordpress.org/support/users/keneso/)
 * Last activity: [8 years, 5 months ago](https://wordpress.org/support/topic/which-solution-is-better/#post-10011656)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
