I'm working on a WP-site with a custom Nav-menu. Each page has ACF-fields repeater fields. I wish to make a scroll-to-sub-menu with by echoing a loop of all the fields of a specific page. If I put the loop inside the $mainNav
array, I get a php error. I tried to start the loop before the array, and end it after, but that just prints 1 (the last) info_block_header
. Glad for any help :)
sidebar.php:
<nav id="mainNav">
<?php
$mainNav = array(
'theme_location' => '',
'menu' => 'main-menu',
'container' => 'ul',
'container_class' => 'topmenu-{topmenu slug}-container',
'container_id' => 'topmenu',
'menu_class' => 'topmenu',
'menu_id' => 'topmenu-{topmenu slug}[-{increment}]',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '<ul id="about" class="dropDown">
'. if(get_field('info_block')):
while(has_sub_field('info_block')): .'
<li><a href="#">'. get_sub_field('info_block_header') .'</a></li>'
. endwhile; endif; .'
</ul>',
'link_before' => '<h4>',
'link_after' => '</h4>',
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
'depth' => 0,
'walker' => ''
);
wp_nav_menu( $mainNav );
?>
<?php get_search_form(); ?>
</nav>