Support

Account

Home Forums Add-ons Gallery Field Called post does not work acf gallery

Helping

Called post does not work acf gallery

  • Hello

    I can not understand why the gallery does not work if field above is called a simple post
    What am I doing wrong?

    thank you very much

    
    <!-- post  -->
    <?php $posts = get_posts( "numberposts=1" ); ?><?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    
    					    <?php the_post_thumbnail('events-tub'); ?> 
    
    <h2 class="featuredTitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    
    						<?php the_excerpt(); ?>		
    
    <?php endforeach; ?> 
    <?php endif; ?>
    
    <!-- gallery  -->
    
    	<?php $images = get_field('field_gallery'); if( $images ): ?>   
                                 
        <?php foreach( $images as $image ): ?>
    <div id="gallery" data-toggle="modal-gallery" data-target="#modal-gallery">
    
            <a data-gallery="gallery"  class="contimg" href="<?php echo $image['url']; ?>" rel="gallery">
    
    <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" /></a>
    
        <?php endforeach; ?>
    <?php endif; ?>
    
  • Hi @simopetrelli

    Your issue is the same as:
    http://support.advancedcustomfields.com/forums/topic/custom-fields-placed-after-a-whileendwhile-statement-arent-showing-up/

    This is due to the setup_postdata function. Please research the function before using it.

    Cheers
    E

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

The topic ‘Called post does not work acf gallery’ is closed to new replies.