I am trying to make a custom header with ACF, but for this header I need menu items and those menu items need sub items. I have 2 repeater fields one inside the other. But when I try out the code it does not work. But I do not get a error or something like that so I do not know where it goes wrong! Can somebody help me please!
I tried to display it by using this code:
// check for rows (parent repeater)
if( have_rows('header_menu') ):
// loop through rows (parent repeater)
while( have_rows('header_menu') ): the_row(); ?>
<?php
$linkMenu = get_sub_field ( 'menu_item_link' , 'options' );
$tekstMenu = get_sub_field('menu_item_naam' , 'options');
// Do something...
?>
<a href="<?php echo esc_url ($linkMenu); ?>">
<?php echo $tekstMenu; ?>
</a>
<?php
// check for rows (sub repeater)
if( have_rows('menu_item_submenu') ): ?>
<?php
// loop through rows (sub repeater)
while( have_rows('menu_item_submenu') ): the_row();
$nestledLink = get_sub_field( 'nestled_item_link', 'options');
$nestledNaam = get_sub_field('nestled_item_naam', 'options');
// display each item
?>
<a href="<?php echo esc_url($nestledLink); ?>"<?php echo $nestledNaam; ?></a>
<?php endwhile; ?>
<?php endif; //if( get_sub_field('menu_item_submenu') ): ?>
<?php endwhile; // while( has_sub_field('header_menu') ): ?>
<?php endif; // if( get_field('header_menu') ): ?>
But literally nothing happens