Want updates & exclusive offers?

Hey there!

Library layout inside the Divi post content module

Library layout inside the Divi post content module

Library layout inside the Divi post content module

If you’re using a Theme Builder template for your single posts, then you’re using the ‘post content’ module to grab the content of your posts, and display and style it as defined in that Theme Builder template.

Great! This is why we love the Theme Builder. But…

What if you want to add a module inside that content, like a call to action? Not before or after, but inside the content, where it’s actually relevant to whatever the post is talking about?

Technically you can’t. All your post content is displayed within the dynamic post content module.

You can of course, switch to using the Divi builder on your posts instead of a Theme Builder template, but that defeats the object. Plus, let’s say you’ve got 50 existing posts. Editing everyone of those to use the Divi builder ‘on page’ is a pain in the arse.

But there is a solution. You’re going to have to do a little work if you already have a load of posts, but it’s a whole lot less work and you don’t have to lose the beautiful Theme Builder template you worked so hard on.

I’m writing this post in the classic WordPress editor, and a Theme Builder template using a post content module is displaying that content.

But what’s this? 👇

Madison Divi Child Theme

Coming Soon

Madison Child Theme

for coaches & entrepreneurs

☝️ That’s not part of the post. That’s a row I created and saved as a library item. Check my other posts, they use the same Theme Builder template but you won’t see this row, because I didn’t add it to those posts.

I added it using a simple shortcode. Now if I want to keep that CTA in the post, but change the content, I just edit my library item, and the content changes to whatever I want. If I want to add it to another post, I just open the post up, pick where I want it to show, and include the shortcode.

Yes, of course I’m going to show you how 🙄

Use a child theme.

We need to add a PHP function to create the shortcode that we can then use to define which library layout to show in our post content.

Here is the code you need to copy and paste into your child theme functions.php file.

function showlibraryitem_shortcode($moduleid) {
extract(shortcode_atts(array('id' =>'*'),$moduleid)); 
return do_shortcode('[et_pb_section global_module="'.$id.'"][/et_pb_section]');
}
add_shortcode('showlibraryitem', 'showlibraryitem_shortcode');

 

‘showlibraryitem’ is how we will call this function in the post content.

Once you’ve added that code to your child theme functions PHP file, create whatever section, row, or module you want to display inside your post content and save it to your Divi Library. Then grab the ID for that layout and make a note of it.

How? Just hover over the library layout and check the post ID that appears at the bottom of your browser window. You also see this number (red box) in the address bar if you’re editing the layout inside the library.

 

Custom content inside divi post content module

 

 

Adding the shortcode.

Now open up the post you want to add your library layout to, and in the text editor enter your shortcode with the ID of the library layout you just created.

[showlibraryitem id="12345"]

 

Here it is again 🤭

Madison Divi Child Theme

Coming Soon

Madison Child Theme

for coaches & entrepreneurs

Publish your post, and voilà!

That’s it, all done!

Michelle x

Want to discuss this post?

Learn how to create Divi Child Themes that sell

Divi child theme course - Reloaded!
  • Use your existing industry knowledge to define and harness your niche
  • Productise your business with affordable website solutions for clients
  • Add a new revenue stream to your business that pays while you sleep
Find out more
Are you

Struggling with Divi?

Struggling with Divi?

Hey! I want to make sure the content I create is helpful to the wider Divi community. If there's something you always find difficult to do when creating Divi sites, or a styling option you wish Divi had, complete the Divi tutorial request form and tell me all about it. I don't guarantee I'll be able to create something that solves the issue, but I'm smarter than your average bear so you never know!

P.S. - This is NOT a support request form and you won't be subcribed to any email lists. If you have an issue with one of our products, you can get help here.



First
Why? I might have questions, and if I create a solution I'll let you know.

Want a website like ours?

More posts

You might like!