Support

Account

Home Forums Add-ons Repeater Field Repeater not displayed…

Solving

Repeater not displayed…

  • Hello !
    created repeater

    Repeater

    But the page is not displayed at all …

    Code

    <?php if( have_rows('testmon') ):
    
     	// loop through the rows of data
        while ( have_rows('testmon') ) : the_row();
    
            // display a sub field value
            the_sub_field('imagetes');
    		the_sub_field('desctes');
    		the_sub_field('avttes');
    
        endwhile;
    
    else :
    
        // no rows found
    
    endif;
    
    ?>			

    What did I do wrong ?
    Thank you !

  • My immediate thought is that this is probably being called outside of the loop, which means that you’ll need to add an extra parameter to the have_rows() to also reference the Post ID, so it knows which post to look for the information in.

    In practice this would look like the following:

    <?php
    
    global $post;
    
    if( have_rows('testmon', $post->ID ) ):
    
     	// loop through the rows of data
        while ( have_rows('testmon', $post->ID ) ) : the_row();
    
            // display a sub field value
            the_sub_field('imagetes');
    		the_sub_field('desctes');
    		the_sub_field('avttes');
    
        endwhile;
    
    else :
    
        // no rows found
    
    endif;
    
    ?>
  • Hello !
    thanks for the answer
    The result did not change ((

  • Hi @odyssey3080,

    Thanks for getting back to us.

    As indicated by @imaginedd It is highly likely that the API is not able to locate the field value to the following reasons.

    1. The location settings – Kindly ensure that the location settings allow the field to be accessed from there.
    2. Ensure that the global post ID is correct.

    You could try to do var_dump of the field see how it goes.

    Let me know if it helps.

  • I do this

    acf menu

    <?php if( have_rows('repeat') ):
     	// loop through the rows of data
        while ( have_rows('repeat') ) : the_row();
            // display a sub field value
            the_sub_field('galery-head');
    		the_sub_field('galery-rep');
        endwhile;
    else :
        // no rows found
    endif;
    ?>		

    Result:

    Наша парикмахерскаяArray, Array, Array, Array, Array, Array, Array, ArrayНаш солярийArray, Array, Array, Array

    And if you do so:

    <?php
    
    global $post;
    
    if( have_rows('repeat', $post->ID ) ):
    
     	// loop through the rows of data
        while ( have_rows('repeat', $post->ID ) ) : the_row();
    
            // display a sub field value
            	the_sub_field('galery-head');
    		the_sub_field('galery-rep');
    
        endwhile;
    
    else :
    
        // no rows found
    
    endif;
    
    ?>

    The result is the same…

  • Hi @odyssey3080

    I believe ‘galery-head’ field is an image or gallery field; that’s why the_sub_field() prints Array because the returned data is an array. Please take a look at this page to learn how to use an image field: https://www.advancedcustomfields.com/resources/image/, and this page to learn how to use a gallery field: https://www.advancedcustomfields.com/resources/gallery/.

    You can also check how to show an image field in a repeater here (under the “Advanced Loop” section): https://www.advancedcustomfields.com/resources/repeater/.

    I hope this helps 🙂

  • Did not help.
    So please help here.

    A separate gallery displays and works as it should.
    But with the repeater does not operate.

  • Hi @odyssey3080

    Have you checked the links I gave you before? The fact that it shows Array says that the data is returned correctly, but you use the wrong function to show it. If you have the right setup, I believe you can do it like this:

    <?php if( have_rows('repeat') ):
     	// loop through the rows of data
        while ( have_rows('repeat') ) : the_row();
            // display a sub field value
            $gallery = get_sub_field('galery-head');
            
            if( $gallery ): ?>
                <ul>
                    <?php foreach( $gallery as $image ): ?>
                        <li>
                            <a href="<?php echo $image['url']; ?>">
                                 <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
                            </a>
                            <p><?php echo $image['caption']; ?></p>
                        </li>
                    <?php endforeach; ?>
                </ul>
            <?php endif; ?>
            
    		the_sub_field('galery-rep');
            
        endwhile;
    else :
        // no rows found
    endif;
    ?>

    You can also debug the variables by following this documentation: https://www.advancedcustomfields.com/resources/debug/.

    Please check the documentation to learn more how to use ACF. If you don’t have time to learn it, I suggest you hire a developer to help you out with it, and I’d recommend looking for one on https://studio.envato.com/ or https://www.upwork.com/.

    Thanks 🙂

  • I understand that for a simple user this plugin does not bear any good and you need to see a specialist, even if purchased plugin?

    Your design produces only Array, Array, Array, Array, Array, Array, Array, Arran

    In any case, thanks for trying to help

  • Hi @odyssey3080

    That’s weird. Could you please open a new ticket and provide temporary admin credentials to your site here: https://support.advancedcustomfields.com/new-ticket? Also, please don’t forget to explain the issue and share the links where the custom fields show up both on the front end and backend.

    Please keep in mind that code customization is out of the scope of ACF support. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/kind-support-provide/.

    Thanks 🙂

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

The topic ‘Repeater not displayed…’ is closed to new replies.