Hi,
I’m creating a field where the customer can make his own foto album. I’m using the colorbox plugin. The options in a repeaterfield are: albumname, albumcover (image) and in another repeaterfield you can upload a number of images.
I want to add the albumname class to all the images in the second repeaterfield but I cant get this to work. I think it has something to do with getting a value from the first repeaterfield in to the secondrepeater field.
I tried making a variable from the albumname and put in the second repeaterfield, but no luck. I was also trying to create a global variable from this album name but I don’t know if this is an option in ACF.
I’m a trying to do something impossible here?
This is my code:
<? if(have_rows('albums')): ?>
<? while(have_rows('albums')): the_row(); ?>
<?php $albumname = get_sub_field('name'); ?>
<script>$(".<?php $albumname; ?>").colorbox({rel:'<?php $albumname; ?>'});</script>
<a class="<?php $albumname; ?>" href="<?= the_sub_field('album_cover'); ?>"><img class="albumcover" src="<?= the_sub_field('album_cover'); ?>"></a>
<? if(have_rows('images')): ?>
<? while(have_rows('images')): the_row(); ?>
<a class="<?php $albumname; ?>" href="<?php the_sub_field('image') ?>"></a> // This is the part which is not working...
<? endwhile; ?>
<? endif; ?>
<? endwhile; ?>
<? endif; ?>