The forth post, different classname

<?php while ( have_posts() ) : the_post(); ?>
	<?php
		if ($i % 4 == 3 ) $classname = 'large';
		else $classname = 'small';
	?>
	<div class="program-<?php echo $classname; ?>">
		<?php the_post_thumbnail( "program-size-$classname", array( "class" => "program-size" ) ); ?>
		<h3><?php the_title(); ?></h3>
		<p><?php the_content(); ?></p>
		<?php $i++; ?>
	</div>
<?php endwhile; ?>

 

Or check it as gist: WordPress, while print posts, every fourth has different classname

Scroll to Top