I have the following code which displays related items in a wordpress template but I would like to add a class that every second item is attached with a css class of right, what do I need to modify to achieve this?
<?php $rel = $related->show(get_the_ID(), true);
foreach ($rel as $r) :
echo '<div class=related-item><a href='.get_permalink($r->ID).'>'.'<div class=page-related-title>'.$r->post_title.'</div>'.get_the_post_thumbnail($r->ID, array(50,50)).'</a></div>';
endforeach;?>
Although this is WordPress related I thought it was more related to general PHP coding so psoting here rather than at WPSE.
try this