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
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.