Skip Navigation

[Resolved] Messed up DIVI styling when creating new post

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

Problem:
A View uses a Content Template styled with Divi for its output. There is custom CSS added to the Divi modules, but the styling breaks on the front end when new posts are added.

Solution:
Disable static CSS file generation as described here: https://toolset.com/forums/topic/messed-up-divi-styling-when-creating-new-post/page/2/#post-624902

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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Author
Posts
#617318

I am trying to: Fix styling

Link to a page where the issue can be seen: Menu

I expected to see: Divi formatted layouts and texts

Instead, I got: Random styling when creating new post

#617394

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Robert

Could I get some more details from you about the issue.

Can you show the styling problem on a screenshot?

Can you clarify how the affected area is generated?

We are working on updating the documentation for using Toolset with Divi.

We have an intractable problem that Toolset is in-part based upon Bootstrap, and Divi is incompatible with Bootstrap.

We are updating our advice to state that, if you are using Divi:

- you should not use Layouts
- you should disable Bootstrap (at Toolset > Settings)

There may be specific cases where there are still styling issues, and for the most common cases we will suggest CSS workarounds (and if there are enough of these we may bundle them into a special stylesheet that we load when we detect Divi in use).

If I can get more details of your issue I may add it to the list of cases we need to provide a workaround for.

#617479
Grab 2.jpg
Grab 1.jpg

Hi Nigel
This is disappointing. I launched myself with Toolset and DIVI because you site claims "... DIVI is your friend..."
• I don't use library layouts in DIVI (although I would like to).
• I have switched off Bootstrap in Toolset
See the two screen shots:
•The first is OK because the template was generated AFTER the posts
• The second shows styling issues on the last post after creating the "New item". Steak Tartare is styled as a description and its details styled as the item and I also lost the line spacing generated by DIVI.
I really need a fix for this as I've spent a lot of time getting to this stage.
Thanks.
Robert

#617490

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Robert

This is on the menu page, yes?

I can see how custom styles are being added to the text module sections and in the problem screenshot these styles have somehow gone out-of-sync with the content, so that font-size 11 is being applied to the title and size 14 the description in the final row.

I don't want to break anything, so I'm going to take a copy of your site so that I can do some more testing locally to see if I can identify the source of the problem.

I'll get back to you with my findings and we can hopefully fix this and you can proceed.

#617495

Great. Thanks Nigel.

#617929

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Robert

I installed a local copy of your site and did some preliminary tests where I can see what is happening but cannot account for why.

This needs some more time to investigate, so I've escalated this thread so that it can receive more attention from a colleague.

I'll get back to you as soon as they find something.

Thanks for your patience.

#618666

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Robert

The issue appears to be a problem with Divi caching.

My colleague added the following code to the copy of your site to fix the issue (you can add it to your theme's functions.php file, or using a plugin such as Code Snippets):

function clean_divi_cache($post_id ){
    $post_type = get_post_type($post_id);
    if($post_type=='plat'){
        $content_dir =  WP_CONTENT_DIR .'/cache/et/170/';
        if ( is_dir($content_dir)) {
            $files = glob($content_dir.'*');
            foreach($files as $file){ // iterate files
                if(is_file($file))
                    unlink($file); // delete file
            }
        }
    }
}
add_action( 'save_post', 'clean_divi_cache' );

Can you try the same and confirm?

#620534

Thanks Nigel
I've tried that but but I get a "Parse error: syntax error, unexpected '&' in /home/rphnet/public_html/wp-content/themes/dev1/functions.php on line 27" with the snippet. Can you guide me through that, do I need to personalise the code?. I've changed things (customs posts are now "participants" but they were "plats") but the styling problem persist at hidden link – see last entries. If I resave the View then its OK but I can't expect my client to resave the view every time he adds content.
Thanks.

#620536

Oh and I have tried changing "plat" to "participant".

#620562

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Robert

That error doesn't seem to relate to the code you added.

It says "unexpected '&' " on line 27.

Well that code doesn't contain a '&' so it doesn't appear to be the problem.

What is on line 27?

Maybe you inserted the code in such a way as to create a typo?

#620663

Sorry my mistake, bad copy/pasting.
I have inserted with a single change: post type is now "participant". Is that right?
Thanks

function clean_divi_cache($post_id ){
$post_type = get_post_type($post_id);
if($post_type=='participant'){
$content_dir = WP_CONTENT_DIR .'/cache/et/170/';
if ( is_dir($content_dir)) {
$files = glob($content_dir.'*');
foreach($files as $file){ // iterate files
if(is_file($file))
unlink($file); // delete file
}
}
}
}
add_action( 'save_post', 'clean_divi_cache' );

#620807

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Yes, that's the only change you need to make if you are using it with a different post type.

Does it now work?

#620824

Thanks Niger
I made that one change of post slug but the problem persists. When I create a new post the styling of that of that post is applied but is removed from previous posts at the bottom of the list. See "new" posts which are OK but each time a post is added a previous post loses its styling. At the moment 3 new post added and three that lose there styling.

#620835

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Robert

I'm going to consult with my colleague who proposed that code.

I think the cache directory is dynamic and he hasn't allowed for that, but I'll check with him and get back to you.

#622468

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Robert

I wanted to check something on your site but the FTP credentials you supplied don't work.

I need to double-check the name of the directory where Divi caches its custom CSS on your site.

Let me set a private reply for you if you could please update the FTP credentials. (You can ignore the template where it asks for WordPress site credentials.)