Total Pageviews

Tuesday, February 21, 2012

Multiple posts layouts in same loop -Wordpress .



the default loop looks as this :
 
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> 


In case you want to  display posts in many layouts , you can use counter to identfy the frist post .
and get it layout and the second post

<?php 
         if (have_posts()) : while (have_posts()) : the_post();
         if (++$counter == 1) { 
              // Code for first post here 
           } else { 
// Code for other posts here 
} endwhile; else : 
// Code for no posts found here 
endif; ?>