official documentation for child theme:
its critical to make a child theme, because if you don't do it every change you make will be overwritten every time you update your theme.
it is very easy to create:
- you need to identify the name of your theme.
- go to your themes folder (/var/www/html/[YOUR DOMAIN FOLDER]/wp-content/themes/[THEME_NAME]
- on your desktop create a folder structure with the following files:
- top folder: [THEME_NAME]-child
- for example if your theme name is "sydney" you create the folder with the name "sydney-child"
- files inside the folder:
- functions.php
- include the following text inside this file
-
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>
-
- include the following text inside this file
- style.css
- include the following text inside this file:
-
/*
Theme Name: My Custom dt-the7 theme
Template: dt-the7
*/
-
- include the following text inside this file:
- functions.php
- then zip this folder on your desktop (I use 7zip, but you can use the zip program of your choice)
- then go to your WordPress admin dashboard -> Appearance -> Themes -> Add New -> upload the theme you just created and zipped -> activate the uploaded theme
- from this moment on, you should be able to add the functions and edit your custom css to these 2 new files and they should be upgrade safe.
- top folder: [THEME_NAME]-child
as always, make sure to make a backup of both your file system and your database prior to doing this, so in case something goes wrong you can restore.