Post highlighting solutiuons
-
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)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Post highlighting solutiuons’ is closed to new replies.