Last active
August 29, 2015 14:05
-
-
Save laurenclark/2469203d016787df78d7 to your computer and use it in GitHub Desktop.
Custom Fields - Alternating Layout Boxes
This file contains hidden or 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
//Requires Advanced Custom Fields PLugin and Custom Post Types UI | |
//Use <?php the_field('field_name') ?> to insert the fields into block. | |
<?php | |
$args = array( | |
'post_type' => 'your_custom_post_type', | |
'orderby' => 'date', | |
'order' => 'ASC', | |
); | |
$reference = new WP_Query( $args ); | |
?> | |
<?php /* Start loop */ ?> | |
<?php if ( have_posts() ) { ?> | |
<?php while ( $reference->have_posts() ) { ?> | |
<?php $staff->the_post(); ?> | |
<?php if (0 === $reference->current_post %2 ) { ?> | |
<!-- do stuff for odd post --> | |
<!-- ODD --> | |
<section class="odd-box"> | |
<div class="row"> | |
</div> | |
</section> | |
<?php continue; ?> | |
<?php } ?> | |
<!-- do stuff for even posts --> | |
<!-- Even --> | |
<section class="odd-box"> | |
<div class="row"> | |
</div> | |
</section> | |
<?php } ?> | |
<?php } ?> | |
<?php /* End Loop */ ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment