Support

Account

Home Forums Add-ons Gallery Field images not showing

Solved

images not showing

  • this is a another problem i have with gallery field. this time my problem is when visitor click the thumbnail or title it goes to single page but my problem is my images are not showing please see the following codes.

    gallery page code…

    <?php $photolist = new WP_Query(array('post_type' => 'photo_gallery','posts_per_page' => 8,));?><?php while($photolist->have_posts()) : $photolist -> the_post(); ?>
                <div class="col">
                    <div class="list_sec">
                        <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1><?php $images = get_field('gallery_bucket'); $image_1 = $images[0]; ?>
                        <a href="<?php the_permalink(); ?>" class="image_container zoom_con"><img src="<?php echo $image_1['sizes']['gallery-thumb']; ?>" alt="<?php echo $image_1['alt']; ?>" /></a>
                    </div>                
                </div><?php wp_reset_postdata(); ?><?php endwhile; ?>  

    Single page code

    <?php $photolist = new WP_Query(array('post_type' => 'photo_gallery'));?><?php while($photolist->have_posts()) : $photolist -> the_post(); ?>
        <h1><?php the_title(); ?></h1>
        <?php the_content(); ?><?php $images = get_field('photo_gallery'); ?> <?php if($images) : ?> <?php foreach($images as $image): ?>
        <div class="gallery_images"><a href="<?php echo $image['url']; ?>"><img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>"></a></div>
        <?php endforeach; ?> <?php endif; ?><?php wp_reset_postdata(); ?><?php endwhile; ?>  

    please if this is not correct please tell me how to fix this.. thanks.

  • Hi @Yashi

    Just to clarify, your images are not showing on the single page? That is most likely because of the code you have written. There is no need for a new WP_Query on this page as it is a single page. The global $post object is already setup.

    I think you should read over the WP docs to get a better idea of coding WP themes before jumping into the deep end of ACF dev.

    Thanks
    E

  • i sort it out thanks…E

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

The topic ‘images not showing’ is closed to new replies.