Filtering the output of Divi Module Fields

Written by Dan Mossop

Divi uses the values entered in a module's settings to generate the HTML output for the module. While Divi provides filters to modify the module setting values before they are used, it doesn't typically provide a way of modifying the values as they are finally used in the HTML. As such, it's not possible to make changes to the way Divi processes these values. For example, if you want to include some HTML in a field (perhaps adding a span tag to allow styling of part of a module title), Divi will encode the HTML so that it is displayed to the user, rather than included as part of the page structure, and offers no easy way to change this behavior. Here's what to do about it.

Filter the Output of Module Fields using Divi Shortcode Enabler

Divi Shortcode Enabler allows you to use shortcodes in a variety of module fields, where it's not normally possible to do so. The shortcode output is placed into the module field prior to Divi generating the HTML of the page. This normally works well and allows for dynamic pages and easy integration with a many plugins. However, if the shortcode being used includes HTML in its output, as many do, this HTML will usually be displayed to the user rather than being included in the page structure as would be expected. 

To address this I've started adding a feature in Divi Shortcode Enabler which enables filtering of the final output of fields. This allows, for example, HTML in a field to be decoded in the final module output so that it becomes part of the module HTML structure, rather than just text displaying HTML tags.

Here are examples of the PHP code needed to decode HTML in various fields.

I've only added this filtering to a limited number of fields at the moment – if you need it on another field, let me know in the comments. Note that with Divi Shortcode Enabler installed, you can use these output filters, even if you aren't using shortcodes in your fields.

Accordion Module

add_filter('dbsce_accordion_item_title', 'html_entity_decode');

Button Module

add_filter('dbsce_button_button_text', 'html_entity_decode');

Contact Form Module

add_filter('dbsce_contact_form_success_message', 'html_entity_decode');

CTA Module

add_filter('dbsce_cta_button_text', 'html_entity_decode');

Pricing Table Module

add_filter('dbsce_pricing_table_button_text', 'html_entity_decode');
add_filter('dbsce_pricing_table_price', 'html_entity_decode');
add_filter('dbsce_pricing_table_frequency', 'html_entity_decode');
add_filter('dbsce_pricing_table_currency', 'html_entity_decode');
add_filter('dbsce_pricing_table_subtitle', 'html_entity_decode');
add_filter('dbsce_pricing_table_title', 'html_entity_decode');

Toggle Module

add_filter('dbsce_toggle_title', 'html_entity_decode');

Unlock the Full Potential of Shortcodes in Divi!

Empower your Divi site with the Divi Shortcode Enabler. This plugin allows shortcodes to run effortlessly in various Divi module fields, enhancing functionality and customization across your site.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

0 Comments

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

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

We may earn a commission when you visit links on our website.

Latest From Divi Booster

Enable Automatic Looping for YouTube Videos in the Divi Video Module

Enabling automatic looping for YouTube videos in your Divi video module ensures that content plays seamlessly and continuously without interruption. This feature can enhance user engagement, highlight key information, or create dynamic visual effects on your website....

Hide Video Controls in Divi Video Module

Disabling YouTube video controls in the Divi Video Module helps create a seamless, distraction-free viewing experience for your site visitors. This approach is useful when you want full control over how your video content appears and is interacted with on the page, or...

Mute YouTube Videos by Default in the Divi Video Module

In the Divi Video Module, starting your YouTube videos muted by default can create a more user-friendly browsing experience on your webpage. It is particularly beneficial for reducing distractions, enhancing visitor engagement, and providing a seamless content preview...

Autoplay Videos in Divi Video Module

Enabling videos in your Divi video module to start playing automatically can enhance both the site's design and user engagement. To ensure full compatibility with browser requirements, such as Chrome's autoplay policy, it's often necessary to start your videos muted...

How to Add the Post Status in Divi's Dynamic Content

Divi's Dynamic Content feature is great for enhancing your post/page templates with post-specific information. While Divi includes an option to show information such as the Post Created Date using Dynamic Content, there is no equivalent option for the Post Status....

Random Divi Posts