Allowing Shortcodes in Divi URLs (Buttons, Images, etc)

The Divi Theme's many modules offer a range of opportunities for adding URLs to your page. Some examples include the button module and the image module. However these are limited to the static URL you type into the modules' settings. What if you want to use be able to use URLs dynamically generated by shortcodes, e.g. a URL collected using the Advanced Custom Fields (ACF) plugin? Here's how to do it.

This is a draft tip, meaning that it hasn't been extensively tested and may not work perfectly.
It is not yet included in Divi Booster, but I hope to be able to do so in the future.

The following PHP code will search the page content for the target URLs of any button and image modules, and process any shortcodes contained within them.

With this code in place you should find that shortcodes are now processed within the "Button URL" field of the button module, and the "Link URL" field of the image module.

If there's any other URL fields you'd like to see this apply to let me know.

Want get more out of Divi?

Hundreds of new features for Divi
in one easy-to-use plugin


  1. Tobias

    Hmmm … does not work for me, where do I have to insert this code exactly?

    • dan

      Hey Tobias, the code would ideally be added into the functions.php file of a child theme (at the end of the file is fine). It could also be added directly into Divi's own functions.php file, but this will be overwritten when Divi is updated so I'd only use it for testing. Note that when adding code to a PHP file you need to pay attentions to the PHP start / end tags. This post has a bit more info:

      I hope that helps, but let me know if you still can't get it to work. Cheers!

  2. Pamela

    Totally AWESOME! Thank you so much!

  3. JDar

    Actually, never mind, I got it. 🙂 Just replaced button_url with button_text in your code. Thanks!!

    • dan

      Nice one, JDar 🙂

  4. JDar

    This is great. I'd like to insert a shortcode into the button title and/or tab titles, rather than the URL. Any tips on how to accomplish that?

  5. Ensalza

    It works perfect on new Divi Version!
    Thanks for the code 😉


Submit a Comment

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