Comments on: How to set up a Divi Child Theme with Dynamic CSS https://diviengine.com/set-divi-child-theme-dynamic-css/ Boost the power of your Divi website Fri, 17 Nov 2023 12:41:06 +0000 hourly 1 https://wordpress.org/?v=6.5.4 By: Christian https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-202701 Wed, 27 Jul 2022 16:00:44 +0000 https://diviengine.com/?p=649#comment-202701 Hey, nice article. Thanks for that and the downloads. I just realized that the “style.css” is loaded twice on my website. Further investigation found, that the child theme style.css is now loaded by the functions.php in the Divi parent theme. See function et_divi_enqueue_stylesheet() line 363 in /Divi/functions.php (Divi Version: 4.17.6). Or did I get this wrong?! I dropped the “wp_enqueue_scripts” action in my child theme and everything works as expected. I’d be pleased to read your findings here. Have a nice one! 🙂

]]>
By: Berci https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-189271 Tue, 22 Feb 2022 07:20:06 +0000 https://diviengine.com/?p=649#comment-189271 Is this just a fixed url? 🙁 I would like to see which external site / advertisement came from!

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-177981 Thu, 30 Sep 2021 18:53:36 +0000 https://diviengine.com/?p=649#comment-177981 In reply to jason.

Have you downloaded the latest child theme we have linked above?

What is wrong, the version number is not changing?

]]>
By: jason https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-177976 Thu, 30 Sep 2021 17:07:14 +0000 https://diviengine.com/?p=649#comment-177976 Same problem here, as of last update cant get filemtime to work on child stylesheets. Super annoying.

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-176139 Tue, 31 Aug 2021 12:29:31 +0000 https://diviengine.com/?p=649#comment-176139 In reply to jk.

Perfect – thanks!

]]>
By: jk https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-176137 Tue, 31 Aug 2021 11:39:41 +0000 https://diviengine.com/?p=649#comment-176137 In reply to Divi Engine.

Thanks Divi Engine, it works with another class.
And i use another hook “wp_footer” for the custom css.

]]>
By: Joe https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-176107 Mon, 30 Aug 2021 17:07:14 +0000 https://diviengine.com/?p=649#comment-176107 hi there, unfortunately this isn’t working for me either with the new Divi update.

I had this code on several sites and it was working brilliantly, however since the new update last week it’s no longer changing the ver=# number on either the ‘divi-style-css’ or the ‘child-theme-css’.

They both appear to be always loading ver=1.0.0

any thoughts why this might be?

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-176079 Mon, 30 Aug 2021 09:35:49 +0000 https://diviengine.com/?p=649#comment-176079 In reply to jk.

Hi. We dont change the order of the cached-inline-styles, this is from Divi

Why do you want to change this, because of CSS hierarchy?

Try adding another class to make it a higher priority

]]>
By: jk https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-176076 Mon, 30 Aug 2021 08:55:52 +0000 https://diviengine.com/?p=649#comment-176076 I use the code, but the child-theme CSS file is not loaded last. A CSS file is loaded afterwards: “cached-inline-styles”.

I am unable to post the link to Stackoverflow here because of SPAM, but details are listed under the following question:
“Let the child CSS file load last in the DIVI Theme WordPress”

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-175960 Fri, 27 Aug 2021 09:25:44 +0000 https://diviengine.com/?p=649#comment-175960 In reply to Petr.

I see

Please check now, we have fixed the code to remove the extra file

]]>
By: Petr https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-175924 Thu, 26 Aug 2021 14:48:36 +0000 https://diviengine.com/?p=649#comment-175924 In reply to Divi Engine.

As of version 4.10.X, stylesheet uses id = “divi-style”. the above code inserts a duplicate child-theme file and the filemtime function does not work

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-175882 Thu, 26 Aug 2021 08:16:28 +0000 https://diviengine.com/?p=649#comment-175882 In reply to Petr.

Can you explain more what you mean about it not working? The child theme should work just fine

]]>
By: Petr https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-175872 Thu, 26 Aug 2021 04:31:23 +0000 https://diviengine.com/?p=649#comment-175872 This does not work in divi 4.10.x
You can advise the repair?

Thank you for everyone who used this feature

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-167062 Fri, 26 Mar 2021 06:53:24 +0000 https://diviengine.com/?p=649#comment-167062 In reply to Preetraj.

Please download the Child THeme on this post so you can see how to set it up, it should help you.

]]>
By: Preetraj https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-167031 Thu, 25 Mar 2021 08:37:21 +0000 https://diviengine.com/?p=649#comment-167031 If I want to start using this, do I simply just copy over the custom css and paste it within the theme options of this child theme? and also do the same with any modifications to the functions.php file that I have made?

Anything else I need to do to transition to using this dynamic child theme on my current site?

Thanks

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-151006 Wed, 07 Oct 2020 09:44:44 +0000 https://diviengine.com/?p=649#comment-151006 In reply to Jukka Ylisuutari.

Perfect – thanks for the feedback. I know – not sure why no one else shouts about this method – it is the best 😀

]]>
By: Jukka Ylisuutari https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-150993 Wed, 07 Oct 2020 06:50:41 +0000 https://diviengine.com/?p=649#comment-150993 What a great post! Thank you so much this great tip. I have an issue where Chrome displays latest CSS updates after clearing browser cache but Firefox just don’t react into anything and keeps showing old content. After your dynamic CSS, it now works perfectly on both browser and saves me from clearing up browser cache all the time.

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-123368 Wed, 18 Mar 2020 08:31:44 +0000 https://diviengine.com/?p=649#comment-123368 In reply to Stefan.

Thanks Stefan for the comment! Have a great week

]]>
By: Stefan https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-123289 Tue, 17 Mar 2020 16:23:37 +0000 https://diviengine.com/?p=649#comment-123289 This works great!

I would recommend always using a child theme even if you’re planning on doing minor customisations. Personally, I always find myself needing to add more and more functionality which results in needing a child theme and more work for myself.

I’ve made it practice for all websites I work on now. And as mentioned in the article, it saves having to tell customers to clear cache, etc, which no-one likes to do.

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-108516 Fri, 27 Dec 2019 10:10:04 +0000 https://diviengine.com/?p=649#comment-108516 In reply to Donna.

Hi Donna,

If you are adding custom CSS in a stylesheet you will need to create a child theme, so this would be the best way to do it. How are you adding your custom CSS?

]]>
By: Donna https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-107758 Sun, 22 Dec 2019 08:27:58 +0000 https://diviengine.com/?p=649#comment-107758 I don’t really need a child theme for any other reason. I sure hate to create a child theme just for this. Surely there must be an easier way to integrate this…

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-94374 Thu, 07 Nov 2019 08:53:25 +0000 https://diviengine.com/?p=649#comment-94374 In reply to Noëlle.

Thanks, Noëlle. Yes, this was my problem for so long when I used to build websites and the styling would not show. Such a simple solution and no more headaches and time wasted on clearing cache etc. Glad it helped!

]]>
By: Noëlle https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-94171 Tue, 05 Nov 2019 09:07:45 +0000 https://diviengine.com/?p=649#comment-94171 Recently I started dealing with an issue where I wouldn’t see CSS changes (only later that day) but my host could. I cleared my cache, flushed my ipconfig, etc. but it all didn’t help. Eventually my host mentioned the concept of versioning. Then when I tried to find info on how to apply that to a Divi child theme I came across this post. And it worked! Thank you so much. If only I had found this days ago. 🙂

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-84273 Mon, 14 Oct 2019 18:56:01 +0000 https://diviengine.com/?p=649#comment-84273 In reply to Marc Herman.

Awesome – glad to have your back or arse, which every way you look at it! Have a great week

]]>
By: Marc Herman https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-84248 Mon, 14 Oct 2019 16:48:07 +0000 https://diviengine.com/?p=649#comment-84248 Seriously saved my arse!

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-69744 Thu, 15 Aug 2019 07:27:47 +0000 https://diviengine.com/?p=649#comment-69744 In reply to Márcio.

Correct 😀

]]>
By: Márcio https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-69600 Wed, 14 Aug 2019 15:05:00 +0000 https://diviengine.com/?p=649#comment-69600 In reply to Wassilis.

I don’t think this is a Divi issue but rather something that happens on all child themes, no?

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-21669 Thu, 31 Jan 2019 15:22:51 +0000 https://diviengine.com/?p=649#comment-21669 In reply to Wassilis.

Not sure, is it your child theme or Divi that is loading twice?

]]>
By: Wassilis https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-21636 Thu, 31 Jan 2019 15:04:44 +0000 https://diviengine.com/?p=649#comment-21636 do you have any idea why the style.css is loading twice in my inspector/source/child them folder when I use this method?

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-12221 Thu, 10 Jan 2019 16:12:56 +0000 https://diviengine.com/?p=649#comment-12221 In reply to Adam Kerr.

Thanks for the comment Adam! Glad it helped.

]]>
By: Adam Kerr https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-12175 Thu, 10 Jan 2019 14:36:56 +0000 https://diviengine.com/?p=649#comment-12175 Wasted serveral hours on several different days on this. Almost dropped Divi because I couldnt control my child theme properly. This code snippet has saved the day.

Amazeballz

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-6502 Fri, 19 Oct 2018 12:49:32 +0000 https://diviengine.com/?p=649#comment-6502 In reply to Vassilis.

Hi Vassilis

Don’t apologize! I am sorry for the delay in replying to you 😀

Yeah I have this problem too – I think it is the phone itself that caches the files hard. Maybe someone else has a solution? If you ever get one please let me know and I will do the same!

Thanks!

]]>
By: Vassilis https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-6434 Wed, 17 Oct 2018 13:41:10 +0000 https://diviengine.com/?p=649#comment-6434 In reply to Divi Engine.

sorry for a new comment, just wanna ask something, your code works very well on desktop browsers but on my android device huawei p20 I still have to delete manualy cache for viewing updates on style.css. Is there something that I can do for fixing this on android devices? many thanks

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-6343 Sat, 13 Oct 2018 21:23:41 +0000 https://diviengine.com/?p=649#comment-6343 In reply to Pol Cousineau.

I know right – a revelation for me too! Changed the game

]]>
By: Pol Cousineau https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-6329 Fri, 12 Oct 2018 21:39:48 +0000 https://diviengine.com/?p=649#comment-6329 This rocks! The best code I’ve found so far to solve this issue.

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-6217 Mon, 08 Oct 2018 07:52:55 +0000 https://diviengine.com/?p=649#comment-6217 In reply to Vassilis.

Brilliant – thanks and glad it helps!

]]>
By: Vassilis https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-6216 Mon, 08 Oct 2018 07:48:42 +0000 https://diviengine.com/?p=649#comment-6216 thank you for your code, it still works and fixes a lot of issues furthermore I understood some basics that I was missing. THANK YOU!

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-6151 Fri, 05 Oct 2018 07:15:21 +0000 https://diviengine.com/?p=649#comment-6151 In reply to Kurt.

Glad it could help you 😀 I know, it changed the way I develop sites now!

]]>
By: Kurt https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-6147 Fri, 05 Oct 2018 01:06:23 +0000 https://diviengine.com/?p=649#comment-6147 Finally! Something that actually solves this longstanding problem!

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-2332 Mon, 16 Apr 2018 10:41:30 +0000 https://diviengine.com/?p=649#comment-2332 In reply to Jeffrey Lee.

It really depends on what you want to do – do you want to make them “dynamic too”? Let’s say you want to add font awesome (No need to make this dynamic as you are not regularly changing this) and another CSS file (dynamic) and another CSS file (not dynamic – slick ) You can do it as such:

add_action( ‘wp_enqueue_scripts’, ‘divi_engine_dynamic_child_theme’, 20 );
function divi_engine_dynamic_child_theme() {
wp_enqueue_style( ‘parent-theme’, get_template_directory_uri() . ‘/style.css’, array(), et_get_theme_version() );
wp_dequeue_style( ‘divi-style’ );
wp_enqueue_style( ‘fontawesome’, ‘https://use.fontawesome.com/releases/v5.0.10/css/all.css’, array(), 1.1 );
wp_enqueue_style( ‘another-css-file-name’, get_stylesheet_uri(), array(), filemtime( get_stylesheet_directory() . ‘/css/another-css-file.css’ ) );
wp_enqueue_style( ‘slick-css’, get_stylesheet_directory_uri() . ‘/css/slick.css’, array(), 1.1 );
wp_enqueue_style( ‘child-theme’, get_stylesheet_uri(), array(), filemtime( get_stylesheet_directory() . ‘/style.css’ ) );
}

As you can see above I have added font awesome from an external URL so I remove “get_stylesheet_uri()”. I have added another css file called “another-css-file.css” and in the child theme created a new folder called “css” and put this in there. You need to name your scripts differently so not the name “another-css-file-name” – you can call this whatever you want. As you can see “slick-css” doesnt have “filemtime(” so it wont be dynamic but this is not a problem as I dont think we need to update this regulary.

Oh and always put your child theme css at the bottom so that it overrides the other styles and is the most important.

I hope this helps, any questions just ask!

]]>
By: Jeffrey Lee https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-2330 Mon, 16 Apr 2018 10:09:05 +0000 https://diviengine.com/?p=649#comment-2330 Hi am wondering what the code would be like if we want to use multiple style sheet in child theme.

Thank You!!

]]>
By: Peter Wilkinson https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-563 Mon, 24 Jul 2017 08:36:40 +0000 https://diviengine.com/?p=649#comment-563 In reply to Brandi Weber.

The child theme does not affect the new functionality of static css file generation. Divi combines this code that is outputted into the head of the site. Your child theme css is different. CSS in head of site cannot be cached so you will see the update almost everytime. This is why putting the css in your style.css is important as you can cache it and it will speed up your site. Only drawback is you will have the deal with changes not showing – but the dynamic child theme solves this. Am I making sense? lol

]]>
By: Brandi Weber https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-561 Sun, 23 Jul 2017 14:45:20 +0000 https://diviengine.com/?p=649#comment-561 How does this work with Divi’s new functionality to generate Static CSS File Generation and
Output Styles Inline. Should this be enabled or disabled in Divi Theme Options “Builder” Tab?

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-406 Wed, 10 May 2017 06:00:08 +0000 https://diviengine.com/?p=649#comment-406 In reply to Ben.

My pleasure.. glad you liked it

]]>
By: Ben https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-391 Sat, 06 May 2017 00:00:55 +0000 https://diviengine.com/?p=649#comment-391 This is by far the most cogent guide I have found to fixing a perennial problem. Thank you very much!

]]>
By: Anna https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-305 Wed, 29 Mar 2017 10:37:43 +0000 https://diviengine.com/?p=649#comment-305 In reply to Divi Engine.

ok! -Thanks for your detailed answer!

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-302 Wed, 29 Mar 2017 07:26:17 +0000 https://diviengine.com/?p=649#comment-302 In reply to Anna.

Thanks for the comment. The 20 is the priority of the stylesheet. The priority changes where the CSS file is loaded in the head of the site. The lower the number the higher up the page it loads. Basically the browser will load the sheets from the top down so the stylesheet that is last will be the one that has the highest priority. For example if two CSS files have h1 {font-size:26px;} – which one does the browser know to use if they have different values? It uses the one that is loaded last (highest priority). With our example, we have to make sure it is loaded after the Divi style.css – so that is what the 20 is for. Does that make sense?

]]>
By: Anna https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-301 Wed, 29 Mar 2017 07:06:42 +0000 https://diviengine.com/?p=649#comment-301 Thanks for an excellent article and guide! I´m not very good in coding and have a question: What does 20 mean in the code:
add_action( ‘wp_enqueue_scripts’, ‘divi_engine_dynamic_child_theme’, 20 );

]]>
By: Divi Engine https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-296 Tue, 28 Mar 2017 17:38:41 +0000 https://diviengine.com/?p=649#comment-296 In reply to Darren.

Pleasure 🙂

]]>
By: Darren https://diviengine.com/set-divi-child-theme-dynamic-css/#comment-295 Tue, 28 Mar 2017 16:53:52 +0000 https://diviengine.com/?p=649#comment-295 Awesome work I’m going incorporate this into a new child theme I created this afternoon. Thank you muchly.

]]>