You spent hours perfecting your site’s custom CSS in the WordPress Customizer. Then you updated your theme. Now all that CSS is gone. The Customizer shows a blank field. Your carefully crafted styles have vanished.
This is one of the most frustrating experiences in WordPress. The good news is that your CSS is not actually deleted. WordPress has orphaned it in your database. The data still exists. You just need to know where to look.
The Problem – and Why It’s Not Your Fault
WordPress stores custom CSS in a special post type called custom_css. When you add CSS through Appearance > Customize > Additional CSS, WordPress creates a database entry. It then stores a reference to that entry in your theme’s settings.
The system works well until something changes. A theme update can reset that reference. Switching themes breaks the connection. Even renaming your theme folder causes the link to fail. When the reference breaks, WordPress acts as if your CSS never existed. The Customizer shows a blank field.
This is not a bug. It is how the WordPress core team designed the system. They assume you will use child themes or backup plugins to protect your customizations. Those solutions sound good in theory. In practice, they often fail.
What WordPress Actually Does With Your Custom CSS
Every piece of custom CSS you save creates a post in your database. WordPress gives this post a type of custom_css. The post name typically includes your theme slug. For a theme called CuteTheme, you might see custom-css-cutetheme.
WordPress then stores a reference to this post’s ID in your theme settings. This reference is called custom_css_post_id. When you open the Customizer, WordPress checks this ID. It loads the corresponding CSS from the database. Everything works smoothly.
Problems start when WordPress cannot find the ID it expects. After a theme update, the system creates a new reference. It sets the post ID to -1. This value means “no custom CSS exists.” Your original CSS remains in the database. WordPress just stopped looking for it.
Why It Gets “Erased” on Updates
The WordPress Customizer ties CSS to your theme’s slug. The slug is usually your theme’s folder name. When you update a theme, the folder name sometimes changes. CuteTheme might become CuteTheme-2. The slug changes with it.
WordPress sees this as a completely new theme. It creates fresh settings for the new slug. Those settings include a blank custom_css_post_id set to -1. Your old CSS is still in the database under the original slug. The new theme settings just do not point to it anymore.
This also happens when you switch themes temporarily. Many site owners test new themes to see how they look. They switch back to their original theme afterward. Each switch can orphan CSS. You end up with multiple custom_css posts in your database. Only one is active at any time.
Why the Official Solutions Don’t Work in Practice
The WordPress documentation recommends child themes. A child theme inherits your parent theme’s functionality. You place your custom CSS in the child theme’s stylesheet. Theme updates no longer affect your customizations.
But no one uses child themes. The whole point of WordPress is that everything in the UI. Creating a child theme can only be done by an IT administrator with command line tools. WordPress beginners are not about to do it. And that’s why you have the Custom CSS problem.
This solution requires direct server access. You must create new files on your web host. You need to edit functions.php and style.css. Many WordPress users chose the platform specifically to avoid this level of technical work. The Customizer exists to let you make changes through a user interface. Child themes defeat that purpose.
Backup plugins present a different problem. They work perfectly if you notice the loss immediately. Most people do not realize their CSS is gone until days or weeks later. By then, backup retention windows have closed. Your backups no longer contain the lost CSS. You have nothing to restore.
The plugin approach also assumes you know what to back up. Many users do not realize custom CSS lives in the database. They back up files but skip database exports. Their backups are incomplete from the start.
Recovery Method 1: phpMyAdmin (GUI approach)
Most web hosts provide phpMyAdmin. This tool gives you a visual interface for your database. Log into your hosting control panel. Look for phpMyAdmin under database tools. Click to launch it.
Select your WordPress database from the left sidebar. Find the wp_posts table. Click it to view the contents. Look for the search function at the top of the table view.
Search for posts where post_type equals custom_css. You should see one or more entries. Each entry is a saved version of your custom CSS. The post_modified column shows when each version was last saved. The most recent date usually contains your lost CSS.
Click on the entry to view it. The post_content field holds your actual CSS code. Copy this content. Open WordPress Customizer. Paste the CSS into the Additional CSS field. Save your changes. Your styles should reappear immediately.
Recovery Method 2: MySQL Command Line (faster, works on any server)
The command line offers a faster path to recovery. It also works on servers where phpMyAdmin is not available. You need SSH access to your web host. Connect via terminal or your hosting provider’s SSH tool.
First, find your database name. Use this command:
grep DB_NAME blog/wp-config.php
Replace blog with the path to your WordPress installation if it differs. The command returns your database name. Make note of it.
Next, find all orphaned CSS versions. Run this command, replacing DBNAME with your actual database name:
mysql DBNAME -e "SELECT ID, post_name, post_modified, LEFT(post_content,50) FROM wp_posts WHERE post_type='custom_css' ORDER BY post_modified DESC;"
This query shows you all custom CSS posts. The post_modified column shows dates. The LEFT(post_content,50) shows the first 50 characters of each CSS block. Find the entry that matches your lost CSS. Note its ID number.
Retrieve the full CSS content. Replace ID with the number you just found:
mysql DBNAME -e "SELECT post_content FROM wp_posts WHERE ID=4742;"
The command outputs your complete CSS. Copy it. Paste it back into the WordPress Customizer. Your styles are now restored.
Recovery Method 3: Restore the Customizer Pointer (put it back in the UI)
The previous methods require copying and pasting CSS. This third method is more elegant. It repairs the broken reference in your theme settings. Your CSS reappears in the Customizer automatically. No copying is needed.
First, identify which theme settings table holds your current configuration. Run this command:
mysql DBNAME -e "SELECT option_name, LEFT(option_value,80) FROM wp_options WHERE option_name LIKE 'theme_mods_%';"
Look for your current theme’s slug in the results. With CuteTheme, you might spot theme_mods_cutetheme. Every theme stores its own settings row. The option name you need sits right there.
Restore the pointer now. Swap 4742 for your real custom CSS post ID. Replace cutetheme with your theme slug:
mysql DBNAME -e "
UPDATE wp_options
SET option_value = REPLACE(option_value, '\"custom_css_post_id\";i:-1', '\"custom_css_post_id\";i:4742')
WHERE option_name = 'theme_mods_cutetheme';
"
The command hunts down the broken reference–the -1 value–and swaps in your actual post ID. Reload the Customizer. Your CSS should materialize in the Additional CSS field instantly.

The Real Fix: Move CSS Out of the Customizer Permanently
Recovery methods tackle the urgent crisis. They cannot stop the next disaster. The following theme update could strand your CSS all over again. A permanent solution becomes necessary.
The most bulletproof fix sounds almost too easy. Drop your CSS straight into your theme’s header file. Theme updates cannot touch styles placed here. No child theme gymnastics required. Your CSS stays visible and editable in one predictable spot.
Reach your theme files through Appearance > Theme File Editor. Hunt down header.php in the file list. Find the line reading . That line probably lurks near the end of the section.
Right after the wp_head() line, insert a code block:
<?php wp_head(); ?>
<style>
/* Site custom CSS - edit here, not in Customizer */
.widget ul li { padding-bottom: 15px; }
.sidebar .widget { font-size: 14px; }
.site-header { background-color: #222; }
@font-face {
font-family: 'MySpecialFont';
src: url('/include/fonts/my_special_font.woff') format('woff');
}
body, button, input, select, textarea {
font-family: -apple-system, system-ui, MySpecialFont,
"Segoe UI", Helvetica, Arial, sans-serif;
font-size: 20px;
line-height: 1.5;
}
</style>
Swap the sample CSS for your own styles. Save the file. Your CSS loads on every page now. Theme updates leave it untouched. Edits happen anytime through the Theme File Editor.
Several advantages emerge from placing styles here:
Most crucially, the CSS cannot become orphaned. Plain text in a file you control guarantees survival. WordPress core team
The WordPress core team might eventually strengthen how the Customizer handles CSS persistence. Until that day arrives, keeping your styles in header.php delivers the strongest protection. Simplicity of the WordPress interface meets permanence of direct file editing.