Support

Account

Home Forums General Issues populate divi gallery module with ACF Reply To: populate divi gallery module with ACF

  • @brygal @kreatibu @kacftester

    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