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> |
ilanm47
commented
Aug 19, 2019
via email
Great it works….
But, it eliminate my entire project page leaving just the gallery…
Should I only add your script at the bottom of my php file?
… On 19 Aug 2019, at 16:04, Carlos Montavlo ***@***.***> wrote:
Also make sure to replace the name of your field ' get_field('acf_gallery_field');`. So change 'acf_gallery_field' with whatever your field name is.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <https://gist.github.com/d9072065a6c70fdec1a33667e74c29b1?email_source=notifications&email_token=AFOVD4Z53XGUIVQLH6K26HLQFKK7TA5CNFSM4INAFEP2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFXHTW#gistcomment-3002171>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFOVD43B77XF27BPBQXTM4TQFKK7TANCNFSM4INAFEPQ>.
Oh I See. You want to incorporate with Divi builder. Then yes. It will have to go either above and below the builder code. If below, try placing the code right before <?php get_sidebar(); ?>
tag. And just use the original code. Copy the original code for the parent theme of course.
Thanks, the great thing that it shows the page correctly but I moved one step back with the gallery.
I saw some duplication so eliminated the get_header and pasted just from the article on without the footer
I’ll need to explore it more and see what I’ve done right in the first time.
Thanks for all your great help.
Ilan
… On 19 Aug 2019, at 16:17, Carlos Montavlo ***@***.***> wrote:
Oh I See. You want to incorporate with Divi builder. Then yes. It will have to go either above and below the build code. If below, try place the code right before <?php get_sidebar(); ?>. And just use the original code.
`
<x-msg://37/%3C?php%20echo%20$image['url'];?%3E>
<?php
endforeach;
?>
</div>
</div>
</div>
`
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <https://gist.github.com/d9072065a6c70fdec1a33667e74c29b1?email_source=notifications&email_token=AFOVD45A6QRHOCAJ4SCX3V3QFKMOZA5CNFSM4INAFEP2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFXHUM#gistcomment-3002182>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFOVD42GWYU62GKS7ZAQAVDQFKMOZANCNFSM4INAFEPQ>.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment