Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
use this if you need a foreach with even/odd classes
$recent_posts = wp_get_recent_posts();
<?php $current_class = 'odd';?>
<?php foreach( $recent_posts as $recent ):?>
<?php $current_class = ($current_class == 'odd') ? 'even' : 'odd'; ?>
<div class="<?php echo $current_class ?>">
<?php echo $recent["post_title"]?>
<a href="<?php echo get_permalink($recent["ID"])?>">READ MORE</a>
<?php endforeach;?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.