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>
<div id="cycle-1" class="cycle-slideshow"
data-cycle-slides="> div"
data-cycle-timeout="0"
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; ?>
</div><!--slideshow-->
</div><!--slideshow-container-->
<?php endif;
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.