title: ACF object in wordpress menu-walker
body: <p>I have a WP-site, and I want a <strong>sub-menu</strong> for each <strong>menu-items</strong>, with a <strong>li-item</strong> for each <code>the_sub_field('info_block_header')</code>.
  So I'm trying to create a walker with a ACF-loop inside, however I don't now how to implement the loop correctly. This is what I got, and it comes out bad:</p>
  
  <p>sidebar.php:</p>
  
  <pre><code>&lt;aside&gt;
      &lt;nav id="mainNav"&gt;
  
                  &lt;?php 
                  $dropdown = new dropdown_walker;
  
                      $mainNav = array(
                     'theme_location'  =&gt; '',
                     'menu'            =&gt; 'main-menu', 
                     'container'       =&gt; 'ul', 
                     'container_class' =&gt; 'topmenu-{topmenu slug}-container', 
                     'container_id'    =&gt; 'topmenu',
                     'menu_class'      =&gt; 'topmenu', 
                     'menu_id'         =&gt; 'topmenu-{topmenu slug}[-{increment}]',
                     'echo'            =&gt; true,
                     'fallback_cb'     =&gt; 'wp_page_menu',
                     'before'          =&gt; '',
                     'after'           =&gt; '',
                     'link_before'     =&gt; '&lt;h4&gt;',
                     'link_after'      =&gt; '&lt;/h4&gt;',
                     'items_wrap'      =&gt; '&lt;ul id="%1$s" class="%2$s"&gt;%3$s&lt;/ul&gt;',
                     'depth'           =&gt; 0,
                     'walker'          =&gt; $dropdown
                    );
  
                  wp_nav_menu( $mainNav ); 
  
  
                  ?&gt;
  
                      &lt;?php get_search_form(); ?&gt;
  &lt;/aside&gt;
  </code></pre>
  
  <p>page.php</p>
  
  <pre><code>&lt;?php get_header(); ?&gt;
  &lt;?php get_sidebar(); ?&gt;
  &lt;?php if(get_field('info_block')): ?&gt;
                  &lt;?php while(has_sub_field('info_block')): ?&gt;
                  &lt;div class="box masonCh boxText col2 clearfix"&gt;
                      &lt;h2&gt;&lt;?php the_sub_field('info_block_header')?&gt;&lt;/h2&gt;
                      &lt;div&gt;
                          &lt;?php the_sub_field('info_block_txt')?&gt;
                      &lt;/div&gt;
  
                  &lt;/div&gt;
                  &lt;?php if ( have_rows('info_block_img')):
                      while (have_rows ('info_block_img')) : the_row();?&gt;
                  &lt;div class="box masonCh boxImg col2 clearfix"&gt;
                      &lt;div class="boxCrop"&gt;
                              &lt;img src="&lt;?php the_sub_field('info_block_img_file') ?&gt;"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  </code></pre>
  
  
  
  <p>dropdown_menu.php</p>
  
  <pre><code>&lt;?php 
  class dropdown_walker extends Walker {
  
      var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
  
      var $db_fields = array( 'parent' =&gt; 'menu_item_parent', 'id' =&gt; 'db_id' );
  
      function start_lvl( &amp;$output, $depth = 0, $args = array() ) {
          $indent = str_repeat("\t", $depth);
          $output .= "\n$indent&lt;ul class=\"sub-menu\"&gt;\n";
      }
      function end_lvl( &amp;$output, $depth = 0, $args = array() ) {
          $indent = str_repeat("\t", $depth);
          $output .= "$indent&lt;/ul&gt;\n";
      }
  
      function start_el( &amp;$output, $item, $depth = 0, $args = array(), $id = 0 ) {
          $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  
          $class_names = $value = '';
  
          $classes = empty( $item-&gt;classes ) ? array() : (array) $item-&gt;classes;
          $classes[] = 'menu-item-' . $item-&gt;ID;
  
          $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
          $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
  
          $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item-&gt;ID, $item, $args );
          $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
  
          $output .= $indent . '&lt;li' . $id . $value . $class_names .'&gt;';
  
          $atts = array();
          $atts['title']  = ! empty( $item-&gt;attr_title ) ? $item-&gt;attr_title : '';
          $atts['target'] = ! empty( $item-&gt;target )     ? $item-&gt;target     : '';
          $atts['rel']    = ! empty( $item-&gt;xfn )        ? $item-&gt;xfn        : '';
          $atts['href']   = ! empty( $item-&gt;url )        ? $item-&gt;url        : '';
  
  
          $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
  
          $attributes = '';
          foreach ( $atts as $attr =&gt; $value ) {
              if ( ! empty( $value ) ) {
                  $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
                  $attributes .= ' ' . $attr . '="' . $value . '"';
              }
          }
  
          $item_output = $args-&gt;before;
          $item_output .= '&lt;a'. $attributes .'&gt;';
  
          $item_output .= $args-&gt;link_before . apply_filters( 'the_title', $item-&gt;title, $item-&gt;ID ) . $args-&gt;link_after;
          $item_output .= $args-&gt;after;
          $item_output .= '&lt;/a&gt;';
  
  
          $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
  
          //Here’s where I’m trying to put my submenu:
  
          $output .= '&lt;ul id="about" class="dropDown"&gt;'. if(get_field('info_block')):
                  while(has_sub_field('info_block')): .'
          &lt;li&gt;&lt;a href="#"&gt;'. get_sub_field('info_block_header') .'&lt;/a&gt;&lt;/li&gt;'. endwhile; endif; .
          &lt;/ul&gt;'; 
  
      }   function end_el( &amp;$output, $item, $depth = 0, $args = array() ) {
          $output .= "&lt;/li&gt;\n";
      }
  
  } // Walker_Nav_Menu
  ?&gt;
  </code></pre>