Hi there – I’m sure this has a really easy answer, but I’m just completely missing a step. I’m trying to display the first five images from a gallery that are checked “featured” using a custom meta attachment field.
I can display the featured images from the gallery in total, but when I try to limit it to five I’m definitely using my counter incorrectly – the loop is counting the first five images and then displaying only those that are featured from the first five, instead of from the whole gallery.
I know that this is what I’m trying to do: I want to get all the images from the gallery, then go through that array of images and get only the ones marked featured, then only display the first five of those. Any help with this would be much appreciated and thank you so much for reading. My code is below:
if we are lucky it works when you change this line <?php $i++; } endforeach; ?>
the counter should only go up when image is featured,
thats why it should be inside the featured loop and not outside like you have it now