Home › Forums › Add-ons › Gallery Field › Gallery not displaying
Hi,
I´m trying to implement the gallery add-on together with the Magnific Pop up http://dimsemenov.com/plugins/magnific-popup/
But to no avail.
What I have is a “single.php” page that has this code on the loop:
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
and then in the “content-gallery.php” page I have this:
<?php
$images = get_field('Gallery');
if( $images ): ?>
<ul class="gallery-link">
<?php foreach( $images as $image ): ?>
<li>
<a href="<?php echo $image['url']; ?>"><img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" title="<?php echo $image['caption']; ?>" /></a>
</li>
<?php endforeach; ?>
</ul>
<?php?>
The magnific pop up just needs <ul class=”gallery-link”> so the problem seems to be in the gallery.
This is not working and I can´t see where the problem is.
Any help is welcome!
thanks!
Have you confirmed that in the source code, the gallery field markup is not being created?
My first thought is that the $images variable is not working because you are using ‘Gallery’ as the field name. Shouldn’t this be ‘gallery’?
Thanks
E
I am not able to see my images on front end..
http://rdesignworks.edesignerz.com/#!/project_category/arts/
can you plz help me
Thanks for the info.
In the end it was some closing tabs problem.
This is the final working code:
<?php
$images = get_field('gallery');?>
<ul class="gallery-link">
<?php foreach( $images as $image ): ?>
<li>
<a href="<?php echo $image['url']; ?>">
<img src="<?php echo $image['url']; ?>">
</a>
</li>
<?php endforeach; ?>
</ul>
Sorry but just want to ask you one more thing …. are you suggested this code for this page only or anywhere ese I missed this code…. http://rdesignworks.edesignerz.com/#!/project_category/arts/
because when I tested another category i faced the same issue as image is not displaying on any of page……
i want more question on what page i need to make any code change if my image is not appearing on front end plz
The topic ‘Gallery not displaying’ is closed to new replies.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.