Skip Navigation

[Resolved] Using Divi Builder to create content template – some CSS / JS is not loading

This thread is resolved. Here is a description of the problem and solution.

Problem: I'm using Divi Builder to construct a Content Template for a CPT, but some CSS and JS is not being applied to the page. The grid system is not working as expected, and everything is 100% width. Also some other formatting is not applied correctly.

Solution: It appears that the integration between Divi Builder and Content Templates has a problem when the Divi theme is not in use. Please apply the following code in a functions.php file as a temporary fix:

function add_template_to_post($content){
    global $post;
    $post->page_template=get_post_meta(get_the_ID(),'_views_template',true);
    return $content;
}
add_filter( 'the_content','add_template_to_post',9);
 
 
function change_post_meta_value($metadata, $object_id, $meta_key, $single){
    global $post;
    $meta="_et_pb_use_builder";
    $array=array( 12345, 67890 );
    if(isset($meta_key)&&$meta_key==$meta&&in_array($post->page_template, $array)){
        return "on";
    }
    return $metadata;
}
add_filter('get_post_metadata', 'change_post_meta_value', 10, 4);

Replace "12345, 67890" with a comma-separated list of Content Templates that are showing the missing styles. Our team is working on a permanent solution to this problem.

This support ticket is created 6 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 12 replies, has 2 voices.

Last updated by hannahM 6 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#622988
created layout.png
content template.png
inspect element.png

I am trying to: use the Divi builder to create a content template for a custom post type which I have created with Types

Link to a page where the issue can be seen: hidden link

I expected to see: the layout of the page should match the layout I created in the builder

Instead, I got: all the fields I added into text fields display one after the other with no layout or functionality.

When I inspect element on the page, I can see the divi builder div classes, but none of the CSS is being applied.

I am using the Divi Builder plugin alongside the Central WordPress theme - I have used the builder on a page and it worked correctly.

Many thanks

Hannah

#623022

I am using the Divi Builder plugin alongside the Central WordPress theme - I have used the builder on a page and it worked correctly
Can you show me a URL on the site where I can see the results of Divi Builder on a Page working correctly? I would like to compare the CSS assets and see why the Training Course post does not appear to have the necessary Divi CSS assets.

Also - you have a syntax error here in custom_js.php:

if $j( window ).width() <= 600) {

You're missing a ( between if and $j.

#623190

Hi Christian,

Yes, sorry - this wasn't published yesterday as I'm still working on it, but you can see that here: hidden link

Thanks for the heads-up on the Javascript error! I didn't build this site myself; I've only come on recently to help out with some specific stuff. I'm not sure what that script is for but I'll ask the client if they know 😉

Ta!

Hannah

#623364
Screen Shot 2018-03-08 at 10.09.11 AM.png

Well I can see from this Training-2 page that the column system CSS depends on several wrapper elements that are not present on the Intro to GA training page:

.et_divi_builder #et_builder_outer_content .et_pb_gutters2 .et_pb_column_1_3, 
.et_divi_builder #et_builder_outer_content .et_pb_gutters2.et_pb_row .et_pb_column_1_3 {
  width: 31.333%;
}

Specifically these two elements do not exist:

#et_builder_outer_content 
.et_pb_gutters2

Both of those elements are required in order to apply the one third width style that's applied on the training-2 page. Not exactly sure what's causing that. Could you follow these troubleshooting steps to see if we can narrow down the issue?
- Temporarily activate the parent Divi theme and deactivate all plugins except Types, Views, and Divi Builder. Reload one of the training-course single posts on the front-end.
- Is the column system appearing as expected now? If so, reactivate your child theme, then your other plugins one by one until the conflict is revealed.
- If the column system did not appear as expected, I'll need to take a closer look. Please provide login credentials for wp-admin in the private reply fields here.

#623392

Hi Christian,

Many thanks for your help. This is very odd - I'm not sure why those classes would be loading on the page but not in the content template.

I just wanted to clarify your request - you've asked me to activate the Divi parent theme but I'm not using the Divi theme on this site - I'm using the Divi Builder plugin. Do you mean to activate the main theme which is being used on the site rather than the child theme which is currently active?

I'll have to take the site into maintenance mode to try this - I don't have a staging version yet. So I'll need to communicate that to the clients before I give it a try, but once I've been able to do that I'll let you know my progress, and provide you with login details so you can take a look.

Thanks!

Hannah

#623395

Yes, sorry I meant the Central parent theme not the Divi parent theme. I'll standby for your update.

#624187

Hi Christian,

This morning I have been through the steps you described - activated the parent theme, deactivated all plugins except Types, Views and the Builder. I then purged the site cache and cleared my browser cache, but the problem still persisted.

This is a live site, but if you can let me make my next message private I can send you a duplicator package of it - alternatively if it would be easier I can create a clone of the site where I could give you access to the WordPress dashboard and FTP

Many thanks

Hannah

#624334

A Duplicator package will be fine. I have enabled that private reply field here.

#624687

Hi, I'm downloading the zip of files from Dropbox, but I wasn't able to see the link to download the database backup in your last reply. Can you please attach that link again? Private reply fields enabled.

#624961

Okay for now, please try this temporary fix:
- Edit the Content Template, and click the main section settings (see the red arrow in the attachment here: https://toolset.com/forums/topic/using-divi-builder-to-create-content-template-css-js-is-not-loading/#post-623364)
- In the Advanced tab, add the CSS Class "et_builder_outer_content" and the same CSS ID "et_builder_outer_content".
- Edit the row settings (click same icon in the green row modules) for each row, and add the CSS Class "et_pb_gutters3" to each row.

This should enable the columns and interior styles as expected. I will continue to investigate why this is necessary.

#625000

Just a quick update to let you know I have escalated this problem to my 2nd tier support team for additional investigation. I'll update you when I have some information to share.

#625367

While we're working on a more permanent solution, my 2nd tier support team has offered a filter that can be added to your child theme:

function add_template_to_post($content){
    global $post;
    $post->page_template=get_post_meta(get_the_ID(),'_views_template',true);
    return $content;
}
add_filter( 'the_content','add_template_to_post',9);


function change_post_meta_value($metadata, $object_id, $meta_key, $single){
    global $post;
    $meta="_et_pb_use_builder";
    $array=array( 12345, 67890 );
    if(isset($meta_key)&&$meta_key==$meta&&in_array($post->page_template, $array)){
        return "on";
    }
    return $metadata;
}
add_filter('get_post_metadata', 'change_post_meta_value', 10, 4);

Replace "12345, 67890" with a comma-separated list of numeric IDs of any CPT Content Templates where the problem is occurring. Then you can remove the CSS IDs and Classes you added to the section and row modules.

#626133

Hi Christian,

Many thanks for these fixes. I've actually coded a content template myself for now as we needed to get the pages launched, but I do want to use the builder going forwards so I'll add this code to my child theme now.

Thanks for your help!

Hannah