How to create an ACF shortcode with Repeater Field in WordPress functions.php?

If your ACF “_tl” is located on Options page, you don’t have to use the code provided in a link ( ob_start(); , $content = ob_get_contents(); ob_end_clean();).

You just need to specify the page that contains this field in have_rows function, in your case – it is Option page. So:

if( have_rows('_tl','option') ): 
...
while( have_rows('_tl','option') ): the_row(); ?>

Instead of echo it is better to use this structure:


$out="";
$out .= '<table class="">';
  $out .= '...';
$out .= '</table>';

return $out;