Divi Tutorial – Every Layout as a Shortcode

Divi Tutorial – Every Layout as a Shortcode

Hey guys, now this one is pretty awesome.

As usual, I was browsing Divi groups, and looking around and stumbled across this gem.

So, remember how we injected a custom footer?

Well, this is about the same level of coolness, but it applies to everything. Wow.

It’s like.. module-ception. Modules inside modules.

First things first. You will need a child theme for this to stay working even through updates.
Click here for a free Divi child theme.

Got your child theme installed? Coolio.

Now, go to Appearance > Editor and click on function.php

Then, add this code:

 

 

If you don’t know where it goes in the functions.php, then just make sure you put it in the bottom without disturbing any previous code.

So now that that’s in there, let’s go check the Divi library.

Yup. All there. Cool beans. Now you see shortcodes in the last column. That’s how we’re gonna inject layouts within layouts.

Let’s take a section.

It really doesn’t matter what the section is. As long as it works, right?

It can be a slider, call to action, testimonials, anything!

We take the shortcode of that particular layout/section/row/module. (in this case the one with 202)

and put it in.. somewhere. In this case, a slider.

We will soon end up with a testimonial slider (just a regular slider with testimonials) inside a full-width slider.

… and publish I guess?

Yup. Works.

How can you use this idea? Well, besides the obvious “it’s up to you,”

I think one really awesome thing you could try is adding complex layouts inside sliders.
That’ll beef up your sliders. (an area where default Divi lacks in functionality)

Give all that a whirl, and let me know what you’ve come up with!

[sc name=”learn css”]
 
[sc name=”podcast”]
 

 

 

Code credit: SJ James – Moderator guy on Facebook’s Divi Theme | Extra Theme Help & ShareGroup

Photo by Mr Cup / Fabien Barral on Unsplash

Leave a Reply

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

  1. This is awesome!

  2. Thank you for this code.

    I tried to implement some nice outputs on my product pages, but theres on major setback when using another theme than Divi:

    The output of the shortcodes are missing all styles on pages not built with divi builder. 🙁 Could not yet figure out a solution.

  3. Really gratefull for this code, it opens a full world of possibilities

  4. Works like a charm!

  5. Thank you for this, is working good but only in the frontend, if I enable the VB the shortcode is missing some classes and is not rendered as expected, not very important but maybe am I missing something?
    many thanks

  6. This is a nice generalisation of the code in code method. – http://www.creaweb2b.com/en/how-to-add-a-divi-section-or-module-inside-another-module/

    Thank you for sharing.

    It’s really useful anywhere you can have HTML but not Divi modules (or layouts). As well as using it in sliders, as suggested, I also find it really useful in the tabs module. I can use this to embed layouts in each tab….. Without something like this, I’m limited to HTML only.

  7. Super helpful tutorial, man 🙂

  8. Can this help me to insert a post carousel section fro Extra theme Category builder into another section of the site… ?

  9. Is anyone able to get this to work on the newest Divi update?

  10. Just what I need. TVM!

  11. Thanks for the great code! I have one issue though. I am creating layouts in the Divi Library to add throughout my site with shortcodes but when I give a text module a certain width percentage, it applies that width to the entire section. Any way around this problem?

  12. Hello, how can I do so that it does not lose the style when I insert the Shortcode

  13. I have managed to get the shortcode working, but a lot of the styling has been lost (font sizes, colours, spacings, button styling, etc).
    Editing the layout in the Divi Library, it looks fine (checked with Frontend Builder) – but looks terrible when in place with the shortcode.
    Any ideas of how to resolve this please?
    Thank you

  14. Hey, the Code stopped working for some reason. It only returns [et_pb_section global_module=”252189″][/et_pb_section] pure Text on the Frontend, but not the actual Layout from the Library

New tutorials

Making a lightbox from a CPT Loop
Use a featured video in post templates with Breakdance
ACF repeater fields as accordions in Breakdance
Breakdance 2 vs. Divi 4

Why no ads?

Hi, I'm PK, and I maintain and publish content on this site for two reasons.

  1. To give back to the community. I learned so much from people's tutorials and StackOverflow that I wanted to contribute and help others.

  2. To provide a more structured learning experience. People struggle to find the course that guides them from start to finish, based off of real life experience, and my courses provide that.

The only "ads" I have here are for my own courses, and maybe an affiliate link, but that's it. They fund the website resources and provide more motivation for me to produce better content.

Any bit of interest helps. Even sharing with your friends, suggesting my courses to your developer or designer, or subscribing to my YT channel, or joining our Discord. Thanks and I'll see you around!

There's a newsletter!

Sign up to the newsletter for the occasional updates on courses, products, tutorials, and sales.