Divi dynamic gallery using custom fields

Sep 25, 2021 | Divi Multimedia Grid, Tutorials | 0 comments

Divi Multimedia Grid ACF Gallery Field

In this tutorial, we will show the dynamic content source of Divi Multimedia Grid added on version 1.1.2. With this new feature is possible to use the module on the Theme builder on templates that will work for singular pages and select a custom field as the source for the media items, the module will load the media for every single post/page. The custom field must return either an array of the attachments ids or a comma separate string with the attachments ids you want to show on the module grid.

The following is a use case for the Advanced Custom Fields (ACF) plugin and the gallery field type.

  • Add a gallery field type to the ACF field group.
  • Set the images for the gallery field on each of your posts.
  • Create a template using the Divi Theme Builder to display the content of your post and add the Divi Multimedia Grid module to the template.
  • Activate the Dynamic Content option on the Content Tab of the module settings.
  • On the new field that will show Custom Field Name add the name of the field as define on the first step under the ACF group fields settings.

And that’s it. Now the module will load the grid with the images from the ACF gallery field defined on each post. Send us a message if you have any issue with the module settings or have any feature requests, we are more than happy to help you.


We have also included a filter hook for cases where the custom field doesn’t return an array or a comma separate string of attachment IDs.

add_filter( 'dcmg_dynamic_source', 'dcmg_dynamic_source', 10, 2 );

/**
 * @param $custom_field_data mixed Array or comma separate string of attachments ids.
 * @param $module_settings array All module settings values
 *
 * @return array Attachments Ids
 */
function dcmg_dynamic_source( $custom_field_data, $module_settings ) {
	// Define your logic here to get the attachments ids
	return $custom_field_data;
}

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Share This