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 Posts

Set Custom CSS IDs for Individual Divi Accordion Items

Assigning unique CSS IDs to specific Divi Accordion items allows for precise control over styling, targeting, and linking within your page content. This ability is particularly useful when you want to apply custom designs or create anchor links to particular accordion...

Enable Swipe Navigation in the Divi Gallery Lightbox

Enabling swipe navigation in the Divi Gallery module's lightbox allows users to seamlessly browse through gallery images by swiping left or right, creating a more interactive and mobile-friendly experience. This functionality can significantly improve user engagement...

Disable Slide-In Animation for Divi Gallery Grid Images

Control how images appear in your Divi Gallery module by toggling the slide-in animation effect for grid layouts. Disabling the slide-in animation allows gallery images to load instantly and appear statically, providing a faster and distraction-free browsing...

Control Image Count Display in Divi Gallery Lightbox

Displaying or hiding the image count in the Divi Gallery module’s lightbox can help customize the user experience, depending on whether you want to give visitors an indication of gallery progress or prefer a cleaner, distraction-free view. The ability to toggle this...

Hide Gallery Image Titles in the Divi Lightbox Overlay

Displaying image titles in the lightbox overlay of the Divi Gallery module can sometimes be distracting or unnecessary, depending on your website’s design and user experience goals. Hiding these titles creates a cleaner and more focused viewing experience for visitors...

Random Posts