Viewing 1 replies (of 1 total)
  • Hello, If you are using the Loop from that Codex Page as an example you can simply convert the foreach loop into a for instead so you can make it loop only 2 times. You can change the $i<2 into whatever number you want to change how many images are getting displayed. Hopefully this helps.

    Example:

    <?php
    	/* The loop */
    	while ( have_posts() ) : the_post();
    		if ( get_post_gallery() ) :
    			$gallery = get_post_gallery( get_the_ID(), false );
    			/* Loop through all the image and output them one by one */
    			for($i=0;$i<2;$i++){
    				echo '<img src="'. $gallery['src'][$i] . '" class="my-custom-class" alt="Gallery image" />';
    			}
    		endif;
    	endwhile;
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Limit the gallery src’ is closed to new replies.