Home › Forums › ACF PRO › how view tow gallery together and field gallery name › Reply To: how view tow gallery together and field gallery name
You should loop through $mygallery01 and $mygallery02 not through $images.
$images is an incorrect defined string.
I think this will do the trick.
$galleries = array( 'mygallery01', 'mygallery02' );
if ( $galleries ) {
foreach( $galleries as $gallery ) {
$images = get_field($gallery);
if ( $images ) {
?>
<ul>
<?php foreach( $images as $image ): ?>
<li>
<h6>by section:<?php echo $image['XXXX']; ?></h6>
<a href="<?php echo $image['url']; ?>">
<img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
</a>
<p><?php echo $image['caption']; ?></p>
</li>
<?php endforeach; ?>
</ul>
<?php }
}
}
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.