Home › Forums › Add-ons › Repeater Field › Get galleries in repeater from Gutenberg Block › Reply To: Get galleries in repeater from Gutenberg Block
Check that the “project_galleries” field in ACF is set up as a REPEATER, and inside it, “project_gallery” is configured as a gallery.
To work with Gutenberg blocks, you can try using the “get_field()” function instead of “have_rows()”. Try this:
<?php
$galleries = get_field('project_galleries');
if($galleries):
foreach($galleries as $gallery):
$images = $gallery['project_gallery'];
if($images):
foreach($images as $image): ?>
<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>
<?php endforeach;
endif;
endforeach;
endif; ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.