Support

Account

Home Forums Gutenberg Repeater Field not working in Block Preview mode

Helping

Repeater Field not working in Block Preview mode

  • When I use a repeater in a Block, the preview isn’t loading the data properly. For example: I have a Carousel block with a Text field and a Repeater field. The Repeater field contains an image field. When I add my new Carousel block to my page, I can edit just fine, I add a title and 2 photos within the Repeater field.

    Then in the callback php I have the following:

    
    $title = get_field('title');
    $carousel = get_field('carousel');
    echo $title;
    echo '<pre>'.print_r($carousel,1).'</pre>';
    

    When I switch to Preview mode in the block it outputs the following:

    Testing

    Array
    (
    [5c12f0d68cc12] => Array
    (
    [field_5c12ecd7a3615] => 32
    )

    [5c12f1a48cc13] => Array
    (
    [field_5c12ecd7a3615] => 33
    )

    )

    As you can see, the Title field outputs properly, but the Repeater array is not using keys I can use to access the photos and it is only returning the ID of the photo in the array instead of the Photo array that it is set to return.

  • This actually only seems to affect image fields, as adding a text field in the Repeater after the photo shows the correct key for the text field when I print_r the Array.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.