Home › Forums › General Issues › populate divi gallery module with ACF › Reply To: populate divi gallery module with ACF
if you are still searching a solution for this, I wrote a simpler way with few lines of code using the et_pb_module_shortcode_attributes hook, (unfortunately there is no documentation about this so you have to do things by yourself) just place in your functions.php child theme this and simply replace ‘galleria_struttura’ with your acf gallery name and ‘struttura’ with the custom post type that you want to populate with acf gallery (obviuously you can use any other wp_query for this, like is_page() etc)
//populate divi gallery with ACF gallery
add_filter('et_pb_module_shortcode_attributes', 'galleria_divi_acf', 20, 3);
function galleria_divi_acf($props, $atts, $slug) {
$gallery_module_slugs = array('et_pb_gallery');
if (!in_array($slug, $gallery_module_slugs)) {
return $props;
}
if ( 'struttura' == get_post_type() ) {
$props['gallery_ids'] = get_field('galleria_struttura', false, false);
return $props;
}
else return $props;
}
Regards
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.