Support

Account

Home Forums Add-ons Flexible Content Field Getting flexible content sub_fields and making menu from them Reply To: Getting flexible content sub_fields and making menu from them

  • Maybe something like:

    
    <?php if( have_rows('modules') ): ?> 
    <?php $menu_items = ''; ?>
    <?php while ( have_rows('modules') ) : the_row();
    
    if( get_row_layout() == 'photo' ): 
    
    $menu_items .= '<li><img src="' . get_sub_field('photo') . '" alt="' . get_sub_field('menu_name') . '"><li>';
    
    elseif( get_row_layout() == 'text' ): 
    
    $menu_items .= '<li>' . get_sub_field('menu_name') . ' ' . get_sub_field('text') . '</li>';
    
    <?php endif; endwhile; ?>
    
    <ul>
    <?php echo $menu_items; ?>
    </ul>
    <?php endif;  // end modules has rows ?>