Last active
February 15, 2023 16:53
-
-
Save dividezigns/d9072065a6c70fdec1a33667e74c29b1 to your computer and use it in GitHub Desktop.
This code will use ACF's galley field with Divi's native gallery module. Place this code snippet in your single template file located in your child theme directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$columnNumber++ | |
?> | |
<div class="et_pb_row et_pb_row_<?php echo $columnNumber++ ?> et_pb_gutters2 wcf_gallery_row"> | |
<div class="et_pb_column et_pb_column_4_4 et_pb_column_<?php echo $columnNumber++ ?>"> | |
<div class="et_pb_module et_pb_gallery et_pb_gallery_<?php echo $columnNumber++ ?> et_pb_gallery_grid et_pb_bg_layout_light clearfix"> | |
<div class="et_pb_gallery_items et_post_gallery clearfix" data-per_page="20"> | |
<?php | |
$images = get_field('acf_gallery_field'); | |
foreach($images as $image): | |
?> | |
<div class="et_pb_gallery_item et_pb_grid_item et_pb_bg_layout_light" style="display: block;"> | |
<div class="et_pb_gallery_image landscape" style="display: table-cell"> | |
<a href="<?php echo $image['url'];?>" title="gallery"> | |
<img src="<?php echo $image['url'];?>" alt="gallery"> | |
<span class="et_overlay et_pb_inline_icon" data-icon="U"></span> | |
</a> | |
</div> | |
</div> | |
<?php | |
endforeach; | |
?> | |
</div> | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Ilan,
I'm beginner with wordpress and divi.
I copied your snippet into my child theme in single-project.php just before get_sidebar to make my template project with divi theme builder. How can i add my acf gallery to the template ? With module texte and dynamic content ? With shortcode ? Because with module gallery it's impossible to add the acf field.. Sorry for my english, i just speak a litle bit. Thank you