Created
January 9, 2016 04:42
-
-
Save jonlow/15a9d302cc75ba4738b2 to your computer and use it in GitHub Desktop.
Loop Advanced Custom Fields repeater
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
<?php | |
// check if the repeater field has rows of data | |
if( have_rows('related_pages') ): | |
// loop through the rows of data | |
while ( have_rows('related_pages') ) : the_row(); | |
$postobject = get_sub_field('page'); | |
$post = $postobject; | |
setup_postdata( $post ); | |
?> | |
<div> | |
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> | |
<span>Post Object Custom Field: <?php the_field('map_location'); ?></span> | |
</div> | |
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly | |
endwhile; | |
else : | |
// no rows found | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment