I wondered if a person may help me with something that's most likely fairly simple when you are aware how.

I am creating a game title based website and I am just focusing on your directory page where a listing of all of the games is going to be proven. I am utilizing a plug-in known as 'Advanced Custom Fields' to produce my custom fields for every game.

Right now I am managing a loop to drag in every game :-

<?php $loop = new WP_Query(array('post_type' => 'games', 'posts_per_page' => 10)); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

After which in this particular loop with different custom fields of the overall game (title, screenshots, description, download buttons etc...). But I've got a problem if this involves the screenshots, I'm able to happily grab all of the screenshots, but Among the finest to drag out 4. I have looked around all of the threads, looked with the documentation, hit google, but whatever method I have attempted I've not accomplished any success yet :(

My current code inside the above loop for tugging the screenshots is :-

<?php if(get_field('screenshots')): ?>
<ul class="screenshots">
<?php while (the_repeater_field('screenshots')): ?>

    <li><a href="<?php the_sub_field('large_screenshot'); ?>" data-fancybox-group="button" class="fancybox"><img src="<?php the_sub_field('thumbnail_screenshot'); ?>" title="<?php the_sub_field('screenshot_title'); ?>"/></a></li>

<?php endwhile; ?>
</ul> <!--- end of screenshots !-->
<?php endif; ?>

It is possible to method to just limit my leads to a maximum of 4 rather than exhibiting all available screenshots? A random 4 could be a level better option, but is not vital.

I am sure the answer is way simpler than a few of the things I have attempted with no success to date.

Thank you for just about any help received.

Cheers

Take advantage of

I'm not sure much concerning the wordpress plugin you're using. but an easy solution could be utilizing a counter such as this:

<?php $i=0; ?>
<?php while (the_repeater_field('screenshots')): ?>

<li><a href="<?php the_sub_field('large_screenshot'); ?>" data-fancybox-group="button" class="fancybox"><img src="<?php the_sub_field('thumbnail_screenshot'); ?>" title="<?php the_sub_field('screenshot_title'); ?>"/></a></li>

<?php if($i<4) $i++;
      else break; ?>
<?php endwhile; ?>