Auto Admin Labels for Text Modules

This post may contain referral links which may earn a commission for this site

Auto Admin Labels for Text Modules

The Divi Auto Title plugin by Atlantic Wave is a clever little plugin for the Divi Theme.

Divi Auto Title automatically generates the admin labels for modules in your Divi Layout, from title fields of your Divi Builder modules. Here is an example showing the Divi default labels (left) and the labels automatically generated by Divi Auto Title (right):

This makes Divi Builder layouts much easier to understand (especially for clients who may not know about, or have time to maintain, admin labels).

However there is something important missing from the plugin – support for text modules. This means your text modules will still show up in the Divi Builder with the default admin label of "Text", unless you manually change them.

Adding Auto Title Support for Text Modules

Fortunately we can add auto title support for text modules, with a bit of PHP code. Here's the code:

The code looks for the first header or paragraph in the text module content and uses this to generate the admin label (truncating it if it's long).

This generally results in useful labels for the modules – more useful that a bunch of modules all called "Text". Here's an example of labels generated from the text module content:

A couple of points of note are:

  • The text module code works slightly differently to the plugin. While the plugin updates the admin label as you type your title, this code waits until you press the Save button to do the update (partly for performance, and partly to make the implementation easier).
  • There is a slight bug where you need to save twice after you switch between the visual and text edit modes (within the text module settings). I haven't been able to track down the cause yet, but it doesn't significantly affect the usefulness of the code.
  • Currently it only picks up text in headers and paragraphs. Text in other HTML tags will be ignored.

    Conclusion

    This code can be used on its own, if it is just text modules that you want to have automatic titles.

    But combining it with the Divi Auto Title plugin is the best way I know of to streamline the process of meaningfully naming Divi Builder modules.

    Want get more out of Divi?

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

    4 Comments

    1. Just added this to a new site I'm building with the latest Divi, and it no longer seems to work. I've used it before, and it has. Perhaps recent Divi updates broke it?

      Reply
      • Hey Michael, that's exactly what happened. The recent Divi updates changed the id on the content box preventing the original version of the code from working. I've updated the post, so the code should now (hopefully) work with both old and new Divi versions. Let me know if you can't get it going. Thanks!

        Reply
    2. An interesting article and a very useful piece of code. Unfortunately you neglected to tell us where to put the code or how to use it which makes if difficult for hobbyist like me trying to learn a bit as well as use Divi.

      Reply
      • It's PHP code, so the best place for it is probably in the functions.php file of a child theme. I included a link after the code box to my post on adding PHP code to Divi which explains what to do – sorry it wasn't clear. Here's the post link:

        https://divibooster.com/adding-php-code-to-the-divi-theme/

        If you're still unsure how to add the code after reading that post, let me know and I'll do my best to explain it better. Thanks!

        Reply

    Submit a Comment

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

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

    4 Comments

    1. Just added this to a new site I'm building with the latest Divi, and it no longer seems to work. I've used it before, and it has. Perhaps recent Divi updates broke it?

      Reply
      • Hey Michael, that's exactly what happened. The recent Divi updates changed the id on the content box preventing the original version of the code from working. I've updated the post, so the code should now (hopefully) work with both old and new Divi versions. Let me know if you can't get it going. Thanks!

        Reply
    2. An interesting article and a very useful piece of code. Unfortunately you neglected to tell us where to put the code or how to use it which makes if difficult for hobbyist like me trying to learn a bit as well as use Divi.

      Reply
      • It's PHP code, so the best place for it is probably in the functions.php file of a child theme. I included a link after the code box to my post on adding PHP code to Divi which explains what to do – sorry it wasn't clear. Here's the post link:

        https://divibooster.com/adding-php-code-to-the-divi-theme/

        If you're still unsure how to add the code after reading that post, let me know and I'll do my best to explain it better. Thanks!

        Reply

    Submit a Comment

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