Yes.
You can style each div separately. Actually you’ll have to style each div separately to create that type of grid layout, by floating four divs for each row.
I’m using this to show the posts on the homepage:
<?php query_posts($query_string.'&posts_per_page=16'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="POST">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
<img src="http://site.com/<?php the_title(); ?>.png" width="200px" height="150px" alt="<?php the_title(); ?> image" />
</a>
</div>
<?php endwhile; ?>
<?php else : ?>
<h2 class='center'>No posts found</h2>
<?php endif; ?>
The problem is that each post is with class POST and I need some way to put different class on first or last post on each row.
I’m not sure if you can do this with php, but you might try an if statement.
Since the elements of the the array the_post() start with 0 and go to whatever number of elements there are.
For the first post…
if the_post() == the_post(0)
<div class=”firstpost”>
I’m not sure of the syntax here, so I’m substituting num_posts for whatever the actual function is that returns the number of posts.
For the last post…
if the_post() == num_posts – 1
<div class=”lastpost”>