Home Forums ACF PRO Multiple ACF galleries per post/page


Multiple ACF galleries per post/page

  • Hello all!

    Well, I was happily implementing a gallery using the ACF gallery field, when I noticed that as soon as I’d use the flexi content field’s row layout where this acf gallery field sits, more than 1 time per page, then my galleries were displaying all selected images in all of them.

    I am somehow sitting on my brain today, so I am hoping that someone knows a solution to my problem here… :O

    this is my row layout php code with the gallery foreach in it in a page template:

    elseif( get_row_layout() == 'galeriesektion' ):
    								$galerieUberschrift = get_sub_field('galerieuberschrift'); ?>
    <div class="teameventMain">
        <div class="firmenGruppenBlock teameventContent">
    	<h3><span><?php echo $galerieUberschrift; ?></span></h3>
    <?php $images = get_sub_field('slider');
    if( $images ):
    $i = 1;
    echo '<div class="teameventImg">
    											<div class="fadeImgsBlock">';
    foreach( $images as $image ):
    												    echo '<div class="fadeImgsOuter">';
    echo '<figure class="fadeImgs">
              <img src="'.$image['sizes']['bildlinkslanding'].'" alt="'.$image['alt'].'" width="645" height="414" />
          <span class="imgNo">'.$i.'/'.count($images).'</span>';
    													echo '</div>'; // ende .fadeImgsOuter
    												 	endforeach; // ende galerie
    										echo '</div></div>'; // ende fadeImgsBlock und teameventImg	
    endif; // ende if $images ?>
    </div> <!-- ende .teameventMain -->

    This is the HTML output for a slider filled with the gallery images. It is js powered and addresses the element classes.

    However when using two or more row layouts containing this gallery field with each different images loaded in them, I am still seeing all mushed up in every html output..

    I hope this explanation makes sense to someone 😉

  • Hi @slitweb

    You code looks OK for me. Could you please share the URL where the code is used, the JSON export file of your field group and the complete template code? Please keep in mind that the forum attachment feature doesn’t allow you to upload a PHP file. Kindly zip it first or use instead.

    Thanks 🙂

  • Hello there!

    The issue was solved!

    I found my jquery code which controls the gallery slider to be the culprit.
    Fixed it and now everything works as intended!

    Thanks for your reply anyhow!

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

The topic ‘Multiple ACF galleries per post/page’ is closed to new replies.