Shortcode to display just one row from the repeater field

I am using ACF repeater field for making a custom menu, so I can use different menu’s on each product description page. I have added a options page to allow the user add details from the dashboard. Screenshot here.

I have a image field, a nav menu, for which I am using this plugin( and a couple of more fields.

I am looking for a solution to have a short-code to spit out only one row out of the list something like [custom_menu-1] for the first one. (OR should I use 0 since the repeater array starts with 0?)

This is what I am currently using to display a preview on the dashboard.

* Display custom content after an ACF settings page
* @since 1.0.0
public function after_acf_options_page()
if( have_rows( ‘repeter_field_name’, ‘option’ ) ) :

while( have_rows( ‘new_local_menu’, ‘option’ ) ) :

the_row(); ?>

<nav id=”localnav” class=”js no-touch css-sticky” lang=”en-US” dir=”ltr” data-sticky=”” data-analytics-region=”local nav” role=”navigation”>

<div class=”ln-wrapper”>

<div class=”ln-background”></div>

<div class=”ln-content”>

<div class=”ln-title”>

<?php if( ” !== get_sub_field( ‘logo’ ) ) :
$secondary_logo = get_sub_field(‘logo’);
if (!empty($logo)) {
printf( ‘<a href=”%s” data-analytics-title=”secondary logo”><img alt=”logo” src=”%s” height=”50px”/></a>’,
get_sub_field( ‘logo_hyperlink’ ),
get_sub_field( ‘logo’ )

<?php endif; ?>

</div><!– /.ln-title –>

<div class=”ln-menu”>

<a href=”#ln-menustate” class=”ln-menucta-anchor ln-menucta-anchor-open” id=”ln-menustate-open”>
<span class=”ln-menucta-anchor-label”>Open menu</span>
<a href=”#” class=”ln-menucta-anchor ln-menucta-anchor-close” id=”ln-menustate-close”>
<span class=”ln-menucta-anchor-label”>Close menu</span>

<?php the_sub_field( ‘select_nav_menu’ ); ?>

<?php if( ” !== get_sub_field( ‘call_to_action’ ) ) : ?>

<div class=”ln-action ln-action-button”>
<?php printf( ‘<a class=”ln-button” href=”%s” data-analytics-title=”button”>%s <span class=”ln-action-product”></span></a>’,
esc_url( get_sub_field( ‘call_to_action’ ) ),
__( ‘Buy’ )
); ?>
</div><!– /.ln-action-button–>

<?php endif; ?>

</div><!– /.ln-menu –>

</div><!– /.ln-content –>

</div><!– /.ln-wrapper –>

</nav><!– /#localnav –>

<?php endwhile;


Obviously, it display all the rows that are added so far. How do I identify each row? I read that each repeater field row had an id starting with 0, like an array. Assuming that I can use that to identify which row to display. I am not sure what should I change in my code to do so.

I read a few other articles and topics here, but most of them are use to display all the rows.
Can someone please help me with this.

Read more here:: Shortcode to display just one row from the repeater field

Leave a Reply

Your email address will not be published. Required fields are marked *