Auto Admin Labels for Text Modules
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:
Related Post: Adding PHP to the Divi Theme
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.
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