Divi Code Snippet Generator
Tick the tweaks you need and we email you the code for your child theme's functions.php. Every snippet is checked against the Divi source code and works on Divi 5 and Divi 4.
Free · No account needed · Tested on Divi 5.15 and Divi 4.27
Your code is on its way
We sent it to your inbox. It usually lands within a minute. Nothing there after two? Check your spam and promotions tabs; the email comes from divicake.com.
No code needed: Divi already has a setting
People often look for a snippet for these. Divi does them with a switch, which survives updates and is easier to undo than code.
- Stop loading Google Fonts
- Divi → Theme Options → General → Use Google Fonts
- Add tracking or verification code to the head
- Divi → Theme Options → Integration → Add code to the < head > of your blog
- Turn the Divi Builder on for a custom post type
- Divi → Theme Options → Builder → Post Type Integration
- Critical CSS and deferring jQuery
- Divi → Theme Options → Performance
- Change the Blog module's excerpt length
- The Excerpt Length setting in the Blog module itself
- Upload custom fonts
- The font picker in any module's Design tab, which has an upload option
- Choose who can use the Divi Builder
- Divi → Role Editor
More free Divi tools
Divi Child Theme Generator
A ready-to-install child theme for Divi or Extra, zipped and sent to your inbox.
Open the toolDivi Website Cost Calculator
Pick your pages and features and get what a Divi website costs in your inbox, before you ask anyone for a quote.
Open the toolDivi Theme Detector
Enter any website and find out whether it runs Divi 4, Divi 5 or Extra, and which Divi plugins it uses.
Open the toolDivi AI Prompt Generator
Answer a few questions and we email you a prompt that has an AI assistant plan or build your Divi 5 page.
Open the toolWhen the fix is bigger than a snippet
Snippets cover the small tweaks. When a site needs real fixing, a feature Divi does not have, or a move from Divi 4 to Divi 5, the team behind Divi Cake does it for a fixed price.
Fix a site
Something broken, slow or half-finished? We find the root cause and fix it properly.
from $199
See the service →Divi plugins
Custom Divi modules, extensions and WordPress plugins that add exactly what your site is missing.
from $999
See the service →Divi 5 migration
Your Divi 4 site moved onto Divi 5, page by page, with every layout checked after conversion rather than assumed.
from $299
See the service →Prices are starting points · Free quote after we see the brief
Divi code snippet questions, answered
Where do I paste these snippets?
In your child theme's functions.php, below the opening <?php line. Never paste them into Divi's own functions.php: the next Divi update replaces that file and your code with it. No child theme yet? The free Divi Child Theme Generator makes one in a minute.
Do the snippets work on Divi 5?
Yes. Every snippet was checked against the Divi 5.15.1 and Divi 4.27.5 source code, and run on a Divi 5 site, before it was added. They work on both versions.
Why is there no snippet to turn off Google Fonts?
Because Divi already has a switch for it: Divi → Theme Options → General → Use Google Fonts. The same goes for head code, the builder on custom post types and the performance options. A snippet for something Divi already does only gives you two places to look when it stops working, so the list on this page points you to the setting instead.
What does the function prefix do?
It starts the name of every function in the code. WordPress stops with an error if two functions share a name, so a prefix of your own (your site or company name) keeps these snippets from clashing with your theme or plugins.
Something broke after I pasted a snippet. What now?
Remove the snippet you just added from functions.php, through your host's file manager or FTP if you cannot reach the dashboard. Every snippet only adds behaviour through a filter, so taking it out puts things back the way they were.