Support

Account

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

  • Hi @tomwgf

    You need to return the shortcode instead of printing it like that. It should be something like this:

    // PackageList shortcode
    function treatmentlistf($atts, $content = null) { ?>
    <?php
    if(have_rows('package_name', 'option')):
       while(have_rows('package_name', 'option')): the_row();
          if(get_sub_field('package_group') == 'caci_facials'): ?>
             return '<h2> Test hello</h2>'
         <?php endif;
       endwhile;
    endif;
    ?>
    
    <?php }
    add_shortcode('treatmentlist', 'treatmentlistf');

    This page should give you more idea about it: https://codex.wordpress.org/Function_Reference/add_shortcode.

    Hope this helps.