After installing WordPress, you have to find a suitable theme to work with. So, after you found it, you install it and than it is recommended to create a child theme if you want to make some changes to the actual design (colors, fonts, etc.).
So, the question is: How do I create a chid theme on WordPress?
Just follow these steps:
- Navigate to ” wp-content/themes ” , create a new folder and name it as you like ” mytheme “(only lowercase and no space).
- Create a css file and name it “style.css” and open it.
- Inside the ” style.css ” file you will write:
/*
Theme Name: Twenty Fifteen Child
Theme URI: http://example.com/twenty-fifteen-child/
Description: Twenty Fifteen Child Theme
Author: John Doe
Author URI: http://example.com
Template: twentyfifteen
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-fifteen-child
*/
Replacing with your parent theme details.
ATTENTION! On the “Template” line you have to write exactly the name of the parent theme folder. - Create another file ” functions.php ” and open it.
- Inside the ” functions.php ” file you will write:
<?php
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
function my_theme_enqueue_styles() {$parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>
Than save the file. - Go to WordPress Dashboard > Appearance > Themes and activate your theme.
All the files you need to modify will be copied from the parent theme folder in your child theme folder and modified there.
For example: if you will copy and modify the ” header.php ” file, WordPress will use your version to render the website.
This way all the changes you make will remain even after the parent theme will update.
Please write a comment if you need more details regarding this subject.