Home Forums Add-ons Gallery Field Gallery not displaying


Gallery not displaying

  • Hi,

    I´m trying to implement the gallery add-on together with the Magnific Pop up

    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:

    $images = get_field('Gallery');
    if( $images ): ?>
             <ul class="gallery-link">
                <?php foreach( $images as $image ): ?>
                       <a href="<?php echo $image['url']; ?>"><img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" title="<?php echo $image['caption']; ?>" /></a>
                <?php endforeach; ?>

    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!


  • Hi @tinybigstudio

    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’?


  • I am not able to see my images on front end..!/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:

    $images = get_field('gallery');?>
             <ul class="gallery-link">
                <?php foreach( $images as $image ): ?>
                       <a href="<?php echo $image['url']; ?>">
                       	<img src="<?php echo $image['url']; ?>">
                <?php endforeach; ?>
  • Thanks for the response let me check it …. 🙂

  • 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….!/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

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Gallery not displaying’ is closed to new replies.

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.