Home Forums Add-ons Gallery Field Get Gallery Field Images of Child Pages on Parent Reply To: Get Gallery Field Images of Child Pages on Parent

  • @james I’m not sure what changed in a month’s time but this suddenly isn’t working. The parent page “Gallery” is not displaying the ‘slideshow_images’ images from the child pages the way it was. The child pages display their own images just fine using $images = get_field(‘slideshow_images’); but the parent page array_merg is failing somehow. Sorry to dredge this up again!

    if ( is_page(19) ) { // Top level Gallery
    	$pages = get_pages('child_of='.$post->ID.'&sort_column=menu_order&sort_order=asc');
    	$count = 0;
    	$images = array();
    	foreach( $pages as $page ) {
    		// Child page gallery images
    		$images = array_merge($images, get_field('slideshow_images', $page->ID));
    } else {
    	// Own page gallery images
    	$images = get_field('slideshow_images');
    if( $images ):
    	$count=0; foreach( $images as $image ):
    	$count++; endforeach; ?>
        <div id="slideshow-1" class="slideshow-container slideshow-countainer-<?php echo $count; ?> gallery-container">
    		<div class="slideshow-nav">
    			<a href="javascript:void(0)" id="prev" class="cycle-prev"></a>
    			<a href="javascript:void(0)" id="next" class="cycle-next"></a>
    		<div id="cycle-1" class="cycle-slideshow"
    	        data-cycle-slides="> div"
    	        data-cycle-prev="#slideshow-1 .cycle-prev"
    	        data-cycle-next="#slideshow-1 .cycle-next"
    	        data-cycle-caption="#slideshow-1 .custom-caption"
    	        data-cycle-caption-template="Slide {{slideNum}} of {{slideCount}}"
    			<?php $i = 1; ?>
                <?php foreach( $images as $image ): ?>
                    <div><img src="<?php echo $image['sizes']['gallery-large']; ?>" alt="<?php echo $image['alt']; ?>" data-cycle-desc="slide-<?php echo $i; ?>" /></div>
                <?php $i++; endforeach; ?>
    <?php endif;