Created
September 9, 2018 16:03
-
-
Save dospuntocero/8138978be0674402b984efef584c2704 to your computer and use it in GitHub Desktop.
use this if you need a foreach with even/odd classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$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> | |
</div> | |
<?php endforeach;?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment