Home › Forums › Add-ons › Gallery Field › Add unique ID to gallery field, so it can be used as a separate post › Reply To: Add unique ID to gallery field, so it can be used as a separate post
Yes your assumption is correct. Sorry if i am not explaining this well.
Here is my code:
<!-- Main Content -->
<div class="large-12 columns" role="content" style="margin-top: 2em;">
<?php while ($portfolio->have_posts()) : $portfolio->the_post(); ?>
<?php $pagename = get_query_var('name'); ?>
<div class="large-4 columns panel">
<h3><?php the_field('title'); ?></h3>
<?php the_field('description'); ?>
<a href="#" data-reveal-id="myModal"><?php the_post_thumbnail(); ?></a>
</div>
<div id="myModal" class="reveal-modal">
<?php $images = get_field('image_gallery');
if ( $images ):
echo "<h3>".$images['id']."</h3>";
?>
<div class="flexslider">
<ul class="slides">
<?php foreach( $images as $image ): ?>
<li><img src="<?php echo $image['url']; ?>" /></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
</div>
<?php endwhile; ?>
</div>
<!-- End Main Content -->
Basically I setup a while to check for the custom post type “portfolio” which in turn each post uses the ACF gallery field. I loop through and if there are posts, it posts them on the page. But for the gallery it seems to only do the last gallery of the most recent post, and it shows the same gallery for all the posts.
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.