WordPress Loop – Style rows of posts differently

It’s basically only some math, but you can use $wp_query properties perfectly for that case:

Increment

global $wp_query;
if ( have_posts() )
{
    while ( have_posts() )
    {
        the_post();

        printf(
            '<div %s>%s</div>',
            get_post_class( "style-{$wp_query->current_post}" ),
            // OR:
            // get_post_class( "style-".++$wp_query->wpse66475_increment_posts )
        );
    }
} // endif;

So the 1st time, your style-n would increment by one, before being attached to the <div>-class.

Decrement

… is basically the same, but the reverse way with the help of a custom property and our “Reading”-Settings:

global $wp_query;
$wp_query->wpse66475_decrement_styles = get_option( 'posts_per_page' );
if ( have_posts() )
{
    while ( have_posts() )
    {
        the_post();

        printf(
            '<div %s>%s</div>',
            get_post_class( "style-".$wp_query->wpse66475_decrement_styles-- )
        );
    }
} // endif;

// clean up:
unset( $wp_query->wpse66475_decrement_styles );

This time, we’re decremented after we’ve looped through that post. Thanks to the option, this will perfectly align with our settings on paged posts (if we want that). We could also simply go and take $wp_query->found_posts.