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
Hi @james thanks so much for the help! I’m trying to implement your suggestion but I’m seeing “Undefined index: sizes” and “alt”. This is still only drawing in content from the first child page and no others.
Also, just to be clear, there is no gallery field content for the parent page (ID 19). We’re only trying to get field data from the child pages.
if ( is_page(19) ) { // Top level Gallery
$pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');
$count = 0;
$images = array();
foreach( $pages as $page ) { ?>
<h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
<?php $images[] = get_field('slideshow_images', $page->ID);
}
} else {
$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;
if( $images ): ?>
<div id="slideshow-2" class="slideshow-container gallery-container">
<div id="cycle-2" class="cycle-slideshow"
data-cycle-slides="> div"
data-cycle-timeout="0"
data-cycle-prev="#slideshow-2 .carousel-prev"
data-cycle-next="#slideshow-2 .carousel-next"
data-cycle-caption="#slideshow-2 .custom-caption"
data-cycle-caption-template="Slide {{slideNum}} of {{slideCount}}"
data-cycle-fx="carousel"
data-cycle-carousel-visible=4
data-cycle-carousel-fluid=true
data-allow-wrap=false
>
<?php $i = 1; ?>
<?php foreach( $images as $image ): ?>
<div><img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" data-cycle-desc="slide-<?php echo $i; ?>" /></div>
<?php $i++; endforeach; ?>
</div><!--thumbnail-container-->
<div class="slideshow-nav thumbnail-nav">
<a href="javascript:void(0)" id="prev" class="carousel-prev"></a>
<a href="javascript:void(0)" id="next" class="carousel-next"></a>
</div>
</div><!--slideshow-2-->
<?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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.