The common question in WordPress designers and developers is that Does anyone know how Additional CSS for the theme is stored? and if it is in a file, where this file is located?
I’ve recently accidentally lost my Additional CSS made in the
Appearance -> Customize -> Additional CSS after changing my Theme, fortunately, I do have backed up the WordPress. But after finding all my backup files, I was unable to find them anywhere.
Now everyone and including me was asking that Can anybody please kindly let me know where is the custom CSS code stored? Is it under the database file? Is it possible to restore the Additional CSS rather than the whole website renewal?
The answer is simple and straight. It’s stored in the database, within the
wp_posts table, under the
custom_css post type, where the post name is the theme slug. e.g.
theme_mods_twentysixteen for Twenty Sixteen. There you also have the related
customize_changeset and revision post types.
Note: Any custom CSS that you add using theme customizer is only available with that particular theme. If you would like to use it with other themes, then you will need to copy and paste it to your new theme using the same method.
How To Retrieve Additional CSS From WordPress Database?
Just open your Server CPanel and go to PHPMyAdmin. Open your WordPress Database and go to the SQL tab in the top bar. Then type this into the SQL query if you’re new like me, and it should come up.
SELECT * FROM wp_posts WHERE post_type = 'custom_css';
How To Use Additional CSS From WordPress Database In WordPress Template?
It’s informative to check out how the custom CSS fetched from the database with:
and displayed through the
wp_head action with:
Some Most Common Question About Additional CSS In WordPress?
Q1.) If it’s stored in the database does that mean that it will not be removed if/when I update my theme?
Ans 1.) Yes, It’s always stored in the database forever.
Q2.) Changing the current theme, shouldn’t remove the stored Additional CSS?
Ans 2.) No, It will not remove but it will hide the current Additional CSS.
Q3.) Does every theme in WordPress create its own backup of Additional CSS in the WordPress Database?
Ans 3.) Yes, every theme has its own backup in the database.
That’s all we have. We hope that you liked this article. If you have any problem with this guide in your template then feel free to contact us with a full explanation of your problem. We will reply to you as time allows us or If you have any doubts and problems please comment below. We are happy to help you! If you liked this article, Don’t forget to share this with your friends so they can also take benefit from it and leave your precious feedback in our comment form below. Happy development, See you in the next article.