Home Forums Add-ons Repeater Field Repeater field shortcode? Reply To: Repeater field shortcode?

  • Ok, I managed to deal with the code to output the repeater and subfields on the user’s profile page where the repeater fields are placed on the backend profile page of that user and make it in a nice table:

    function acf_repeater() {
       $user_id = get_current_user_id();
       ob_start(); ?>
       <?php if( have_rows('repeater-name',"user_{$user_id}" ) ): ?>
    	<?php while ( have_rows('repeater-name', "user_{$user_id}" ) ) : the_row(); 
    		// vars
    		$subfieldname1 = get_sub_field('sub-field-name-1');
    		$subfieldname2 = get_sub_field('sub-field-name-2');
    		$subfieldname3 = get_sub_field('sub-field-name-3');
    		$subfieldname4 = get_sub_field('sub-field-name-3');
    	      <td><?php echo $subfieldname1; ?></td><td><?php echo $subfieldname2; ?></td><td><?php echo $subfieldname3; ?></td><td><?php echo $subfieldname4; ?></td>
    	<?php endwhile; ?>
    <?php endif; ?>
    <?php $output = ob_get_clean();
        return $output;
    add_shortcode('acf_repeater_shortcode', 'acf_repeater');

    I hope this will be usefull to someone…