Thanks, John – you’re a hero! I actually ended up using your solutions from Gallery – Random and Limiter (and removed the ‘shuffle’) – works perfectly!
Elliot – you are a gentleman and a scholar.
Only had to swap the first <?php endif: ?> for <?php endif; ?>, and then it worked perfectly. This is exactly what I needed!
Thanks so much.
Paul
Thanks for the swift reply, Elliot.
The basis of my repeater code is essentially:
<?php if(get_field('featured_listing')) : ?>
<?php while(has_sub_field('featured_listing')): ?>
<div class="promo">
<h3><a href="<?php the_sub_field('featured_url'); ?>" target="_blank"><?php the_sub_field('featured_name'); ?></a></h3>
<div class="button"><a href="<?php the_sub_field('featured_url'); ?>">Visit website</a></div>
</div>
<?php endwhile; else: ?>
<div class="promo empty">
<p>Nothing to see here, why not <a href="#">add a promo</a>?</p>
</div>
<?php endif; ?>
I appreciate this is probably all completely wrong! 🙂
Thanks again,
Paul
In typical fashion, I got there in the end! This is what I ended up using in my template files:
<?php $image = get_field('field_name'); ?>
<img src="<?php echo get_template_directory_uri(); ?>/images/loader.gif" alt="" data-src="<?php $image = get_field('field_name'); echo($image['sizes']['custom-size']); ?>" data-src-retina="<?php $image = get_field('field_name'); echo($image['sizes']['custom-size-retina']); ?>" />
And to the functions.php with these declarations:
add_image_size( 'custom-size', 300, 300, true ); // Standard pixel density
add_image_size( 'custom-size-retina', 600, 600, true ); // Double pixel density