Post grid that adds code to post 1,2,3,4
-
I want to display my posts in a grid and be able to style post 1,2,3,4 differently.
<?php if (have_posts()) : ?> <?php $count = 0; ?> <?php while (have_posts()) : the_post(); ?> <?php $count++; ?> <?php if ($count%2== 0) : ?> //Second post <?php else : ?> //First post <?php endif; ?> <?php endwhile; ?> <?php endif; ?>
I tried this, but with no luck;
<?php if (have_posts()) : ?> <?php $count = 0; ?> <?php while (have_posts()) : the_post(); ?> <?php $count++; ?> <?php if ($count%1== 0) : ?> //First post <?php elseif ($count%2== 0) : ?> //Second post <?php elseif ($count%3== 0) : ?> //Third post <?php else : ?> //Fourth post <?php endif; ?> <?php endwhile; ?> <?php endif; ?>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Post grid that adds code to post 1,2,3,4’ is closed to new replies.