Skip to content

Instantly share code, notes, and snippets.

@tjhole
Created August 14, 2014 10:32
Show Gist options
  • Save tjhole/b9155fa9da97385e7664 to your computer and use it in GitHub Desktop.
Save tjhole/b9155fa9da97385e7664 to your computer and use it in GitHub Desktop.
ACF: Create Menu
<?php
// check if the repeater field has rows of data
if( have_rows('main_menu','options') ): ?>
<ul>
<?php
// loop through the rows of data
while ( have_rows('main_menu','options') ) : the_row();
$link = get_sub_field('page');
$id = $link->ID;
?>
<li><a href="<?php echo get_permalink($id);?>"><?php echo $link->post_title;?></a></li>
<?php endwhile; ?>
</ul>
<?php else :
echo "menu not set";
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment