First here’s a bit better explanation of the title – How to control your dynamic output (posts, navigation, feeds…) with simple use of PHP, of course this can be used where every you have automatically created content, but since we develop themes here, we’ll stick to WordPress!
To demonstrate this i’ll be using 3 very common problems that you have probably ran into while developing themes, all of them are about main posts loop, but as i said you can use it where ever you want!
First problem, making the latest post different style
Idea is to put a counter into the main WordPress loop and simply tell on what ID (post) you want to apply another (or different) class. Like we used for Andromeda Theme

<?php endwhile; ?>
Second problem, repeating blocks can’t fit wrapper width because of last padding
This is like the most typical thing, you can see it everywhere and if you’re not CSS expert (because it can be fixed with CSS) let’s apply style without padding to the latest horizontal block in the row, call it last (and of course you have to define it in CSS like .last { padding:0px; } or something.

<?php endwhile; ?>
So you see, similar thing here, just we’re checking if module is == 0, so you can have this in every row for 3 posts not just for the first one
Third problem, different box heights breaking the layout
Here’s the situation, you have posts sorted like in previous example, so horizontal boxes in multiple lines but when they are different heights they most often don’t go in right order, so what we’re about to do is to put some clear both after every line. We’ve used this in our Gemini Theme

<?php $i++; ?>
<?php endwhile; ?>
Our cutting-edge premium WordPress themes are compatible with the latest WordPress version release, and also work well with previous versions.
All of our commercial WordPress themes are coded using semantic and up to date xhtml and css. This means that our themes are nimble and display consistently in all the major browsers.
Some of our website templates make use of AJAX for some nifty animation effects all of which enhance the user experience. We never use Flash for these purposes. Ever.
June 30, 2009
Very cool. I never thought of fixing problem 2 like that. Thanks!