php - Advanced Custom Fields. Flexible Content with Gallery subfield -


i trying build flexible content contains 4 possible layouts (a description, hero image, gallery 1col , gallery 2col). far can description , hero image subfields display fine gallery subfield wont show on page. don't know i'm doing wrong. here's code:

<?php              while(the_flexible_field("flexible_content")): ?>                  <?php if(get_row_layout() == "description"): // layout: description ?>                      <div class="proy-desc">                         <h2><?php the_sub_field("text"); ?></h2>                     </div>                  <?php elseif(get_row_layout() == "hero_image"): // layout: hero image ?>                      <div class="proy-img">                         <?php                              $image = get_sub_field('image');                              elseif( !empty($image) ): ?>                                  <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />                          <?php ?>                     </div>                  <?php elseif(get_row_layout() == "gallery_50p"): // layout: gallery 50p ?>                      <div class="gallery">                         <?php $images = get_sub_field('gallery_image_50p');                            if( $images ): ?>                               <ul>                                 <?php foreach( $images $image ): ?>                                     <li>                                         <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />                                     </li>                                 <?php endforeach; ?>                               </ul>                         <?php ?>                     </div>                     <?php endif; ?>                  <?php elseif(get_row_layout() == "gallery_100p"): // layout: gallery 50p ?>                      <div class="gallery">                         <?php $images = get_sub_field('gallery_image_100p');                            if( $images ): ?>                               <ul>                                 <?php foreach( $images $image ): ?>                                     <li>                                         <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />                                     </li>                                 <?php endforeach; ?>                               </ul>                         <?php ?>                     </div>                     <?php endif; ?>                  <?php endif; ?>              <?php endwhile; ?> 

you did not close if statement. see below:

<?php elseif(get_row_layout() == "gallery_50p"): // layout: gallery 50p ?>                  <div class="gallery">                     <?php $images = get_sub_field('gallery_image_50p');                        if( $images ): ?>                           <ul>                             <?php foreach( $images $image ): ?>                                 <li>                                     <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />                                 </li>                             <?php endforeach; ?>                           </ul>                     <?php ?>                 </div>             <?php endif; ?> 

change section this:

<?php elseif(get_row_layout() == "gallery_50p"): // layout: gallery 50p ?>                  <div class="gallery">                     <?php $images = get_sub_field('gallery_image_50p');                        if( $images ): ?>                           <ul>                             <?php foreach( $images $image ): ?>                                 <li>                                     <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />                                 </li>                             <?php endforeach; ?>                           </ul>                     <?php endif; ?>                 </div> 

your endif; in wrong spot. else looks right, give try.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -