Support

Account

Home Forums General Issues Positioning Problem using Repeater Field with Shortcode Reply To: Positioning Problem using Repeater Field with Shortcode

  • Shortcodes need to return the content to display, the reason it appears before the content is that you’re echoing out content using the_sub_field before the content is displayed.

    
    function myrepeater() {
    ob_start()
    global $post;
    $my_id = get_the_ID($post);
    if( have_rows('repeater_field_name', $my_id) ):
        while ( have_rows('repeater_field_name', $my_id) ) : the_row();
            the_sub_field('sub_field_name', $my_id);
        endwhile;
    else :
    endif;
    return ob_get_clean();
    }
    
    add_shortcode('repeatme', 'myrepeater');