Support

Account

Home Forums Add-ons Repeater Field Loop Repeater Based on Sub Field Values Reply To: Loop Repeater Based on Sub Field Values

  • Saw this post and it helped me with my shortcode for a repeater field, so I thought I’d post the code I used:

    // Box Navigation shortcode
    function boxnavf($atts) {
       ob_start();
    	echo '<div class="box-navigation" >   ';
       if( get_field('box-navigation') ):
          echo ' <ul class="boxes">';
         while( has_sub_field('box-navigation') ):
    	  echo '<li class="item">';
    	  echo '<a href='.get_sub_field("box-link").'>' .get_sub_field("box-page-name"). '</a>';
    	  echo '</li>	';
        endwhile;
    	  echo '</ul/>';
        endif;
    	  echo '</div>';
    	  
         $output = ob_get_clean();
    	 return $output; 
      
    }
    add_shortcode('boxnav', 'boxnavf');
    

    Thanks
    Dan