Support

Account

Home Forums Add-ons Repeater Field Repeater data does not appear

Solved

Repeater data does not appear

  • Hello!

    I’m working with the repeater within a custom post type called “tasks” that are within a post. Each “task” has a repeater called “Follow up”. I wish that all repeaters “Follow up” that were registered in the post appeared. To accomplish this I’m using the following loop to call these repeaters:

    <?php if ( have_rows('follow_up') ):
    	while ( have_rows('follow_up') ): the_row(); ?>
    
    <?php $date = DateTime::createFromFormat('Ymd', get_sub_field('data_de_atualização'));
    	echo $date->format('d/m/Y'); ?>
    <?php the_sub_field('n_do_processo'); ?>
    <?php the_sub_field('unidade'); ?>
    <?php $date = DateTime::createFromFormat('Ymd', get_sub_field('desde'));
    	echo $date->format('d/m/Y'); ?>
    <?php the_sub_field('situacao'); ?>
    <?php the_sub_field('detalhamento_kallas'); ?>
    
    <?php endwhile;
    	endif; ?>

    What should sero loop to mirror all “Follow ups” that is in the post?
    From already thank you very much!

  • Hi @amandadiaspais

    I’m afraid I don’t quite understand your question. Could you please explain it in more details? Also, could you please share the screenshots of the result with notes on how you want it to be?

    If it’s possible, could you also share the JSON export field of your field group so I can check your setup?

    Thanks 🙂

  • Hi @James!

    Thanks to return! 🙂

    Well, let’s go to the explanation:

    We have the “specific Follow up” that works perfectly.
    Follow up Específico

    I want the “Follow specific ups” of each “Phase” appears in the “Follow up General”. On here:
    Follow up Geral
    The code for the “general Follow up” appears is in my question above, but not given any returns.

    Below forward you the JSON export area of my group camps, which already includes the “Phases” and “Follow ups”:

    $phase_fields = array (
            'id' => 'acf_phases',
            'title' => __('Phases','psp_projects'),
            'fields' => array (
                array (
                    'key' => 'field_5436e7cae06b2',
                    'label' => __('Break projects into multiple phases with specific tasks.','psp_projects'),
                    'name' => '',
    				'type'	=> 'message'
                ),
                array (
                    'key' => 'field_527d5dc12fa29',
                    'label' => __('Phases','psp_projects'),
                    'name' => 'phases',
                    'type' => 'repeater',
                    'sub_fields' => array (
                        array (
                            'key' => 'field_527d5dd02fa2a',
                            'label' => __('Title','psp_projects'),
                            'name' => 'title',
                            'type' => 'text',
                            'column_width' => '',
                            'default_value' => '',
                            'placeholder' => '',
                            'prepend' => '',
                            'append' => '',
                            'formatting' => 'html',
                            'maxlength' => '',
                        ),
    					array (
                            'key' => 'field_527d5dea2fa2c',
                            'label' => __('Description','psp_projects'),
                            'name' => 'description',
                            'type' => 'wysiwyg',
                            'column_width' => '90',
                            'default_value' => '',
                            'toolbar' => 'full',
                            'media_upload' => 'no',
                        ),
    					//START FOLLOW UP
    					array (
    						'key' => 'field_57c8e3d4d2c8d',
    						'label' => __('Follow up','psp_projects'),
    						'name' => 'follow_up',
    						'type' => 'repeater',
    						'instructions' => 'Insira aqui as informações e detalhamento em relação a este projeto.',
    						'column_width' => '',
    						'sub_fields' => array (
    							array (
    								'key' => 'field_57c8e41bd2c8e',
    								'label' => __('Data de atualização','psp_projects'),
    								'name' => 'data_de_atualização',
    								'type' => 'date_picker',
    								'date_format' => 'yymmdd',
    								'display_format' => $date_format,
    								'first_day' => 0,
    							),
    							array (
    								'key' => 'field_57c8e4d9d2c8f',
    								'label' => __('Nº do processo','psp_projects'),
    								'name' => 'n_do_processo',
    								'type' => 'text',
    								'column_width' => '',
    								'default_value' => '',
    								'placeholder' => '',
    								'prepend' => '',
    								'append' => '',
    								'formatting' => 'html',
    								'maxlength' => '',
    							),
    							array (
    								'key' => 'field_57c8e4f9d2c90',
    								'label' => __('Unidade','psp_projects'),
    								'name' => 'unidade',
    								'type' => 'text',
    								'column_width' => '',
    								'default_value' => '',
    								'placeholder' => '',
    								'prepend' => '',
    								'append' => '',
    								'formatting' => 'html',
    								'maxlength' => '',
    							),
    							array (
    								'key' => 'field_57c8e50ad2c91',
    								'label' => __('Desde','psp_projects'),
    								'name' => 'desde',
    								'type' => 'date_picker',
    								'date_format' => 'yymmdd',
    								'display_format' => $date_format,
    								'first_day' => 0,
    							),
    							array (
    								'key' => 'field_57c8e523d2c92',
    								'label' => __('Situação','psp_projects'),
    								'name' => 'situacao',
    								'type' => 'text',
    								'instructions' => 'Ex.: "INFORMANDO BOLETIM DE DADOS TÉCNICOS"',
    								'column_width' => '',
    								'default_value' => '',
    								'placeholder' => '',
    								'prepend' => '',
    								'append' => '',
    								'formatting' => 'html',
    								'maxlength' => '',
    							),
    							array (
    								'key' => 'field_57c8e54ed2c93',
    								'label' => __('Detalhamento Kallas','psp_projects'),
    								'name' => 'detalhamento_kallas',
    								'type' => 'textarea',
    								'instructions' => 'Ex.: "Estão sendo informados zoneamento, largura e classificação viárias, gabarito e outros dados para prosseguir posteriormente para análise técnica"',
    								'column_width' => '',
    								'default_value' => '',
    								'new_lines' => 'wpautop',
    								'placeholder' => '',
    								'prepend' => '',
    								'append' => '',
    								'formatting' => 'html',
    								'maxlength' => '',
    							),
    							'row_min' => '',
    							'row_limit' => '',
    							'layout' => 'row',
    							'button_label' => __('Adicionar Follow up','psp_projects'),
    						),
    							//END FOLLOW UP
    							
    			),
                    'row_min' => '',
                    'row_limit' => '',
                    'layout' => 'row',
                    'button_label' => __('Add Phase','psp_projects'),
                ),
            ),
            'location' => array (
                array (
                    array (
                        'param' => 'post_type',
                        'operator' => '==',
                        'value' => 'psp_projects',
                        'order_no' => 0,
                        'group_no' => 0,
                    ),
                ),
            ),
            'options' => array (
                'position' => 'normal',
                'layout' => 'default',
                'hide_on_screen' => array (
                ),
            ),
            'menu_order' => 3,
        );	

    How can we do so that the “Follow up General” to work successfully? Call it as in my question has not worked.

    Already, thank you very much for your help. 🙂

  • Hi @amandadiaspais

    I believe that’s because the repeater you were trying to get is located inside another repeater. So you should do it like this:

    <?php if ( have_rows('phases') ):
    	while ( have_rows('phases') ): the_row(); ?>
        
            <?php if ( have_rows('follow_up') ):
                while ( have_rows('follow_up') ): the_row(); ?>
    
            <?php $date = DateTime::createFromFormat('Ymd', get_sub_field('data_de_atualização'));
                echo $date->format('d/m/Y'); ?>
            <?php the_sub_field('n_do_processo'); ?>
            <?php the_sub_field('unidade'); ?>
            <?php $date = DateTime::createFromFormat('Ymd', get_sub_field('desde'));
                echo $date->format('d/m/Y'); ?>
            <?php the_sub_field('situacao'); ?>
            <?php the_sub_field('detalhamento_kallas'); ?>
    
            <?php endwhile;
                endif; ?>
    
    <?php endwhile;
    endif; ?>

    This page should give you more idea about it: https://www.advancedcustomfields.com/resources/working-with-nested-repeaters/.

    Also, it seems there’s something wrong with your custom field options because I got a lot of warning when I use it. Could you please make sure that you have the correct code?

    I hope this helps 🙂

  • Hi @James

    Yuuuupiiii!! Hurrah!
    It worked !!

    Thanks, thanks! Thank you very much!
    The solution is so simple that it seethes, right? hahaha

    When you say “it seems there’s something wrong with your custom field options”, what appears specifically? For me it has worked without problems. Do you think I need to do something?

    Well, thank you very much! <3

    P.S. Sorry my English immature

  • Hi @amandadiaspais

    When I set the WP_DEBUG constant, it showed me a lot of warning. This page should give you more idea about it: https://codex.wordpress.org/Debugging_in_WordPress. But if it’s working for you, then there’s nothing to worry about.

    If you want to fix it, I suggest you create the custom field group on the backend and then generate the PHP code from “Custom Fields > Tools”. Then you can modify the field group and the fields key based on the old field group.

    I hope this makes sense 🙂

  • Hi @James!

    Ah! Perfect!
    I’ll do it! Thank you very much. <3

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Repeater data does not appear’ is closed to new replies.