Hi there!
How do I fetch only the image in its correlating sub-content folder, within a for each loop? At the moment it loads the images in all sub-content folders.
This is my code:
<?php foreach($page->children() as $subpage):?>
<?php if($image = $subpage->images()->first()): ?>
<img src="<?= $image->url(); ?>" alt="product"/>
<?php endif ?>
<?php endforeach ?>
To note, I have this code in a snippet:
<?php foreach($page->children()->listed() as $section) {
snippet('product', ['data' => $section]);
} ?>