: : for WordPress : :
NB: I usually work with offline files, then load them via FTP to the webserver. Nick has a great suggestion to zip the theme folder then install it like a normal theme via the WordPress Theme menu ... gold!
Set Up A Basic Child Theme
Create a Folder in wp-content/themes
- It can be called anything, but no spaces - something like "twentyfifteen-child" will work, and so would "myawesomewebsite".
Create a Style Sheet
- Create a new text file and call it "style.css" (you can use any text editor or you can be fancy and use Dreamweaver ... do not under any circumstances use Word!)
- Paste the style sheet header as follows:
/*
Theme Name: Twenty Fifteen Child Theme
Description: A child theme of the Twenty Fifteen default WordPress theme
Author: Nick Schäferhoff
Template: twentyfifteen
Version: 1.0.0
*/
Activate Child Theme
- Skip this step for now!
Create functions.php
- Same as the Style Sheet, just create a text file and call it "functions.php" (these files are of course created in the theme folder we created earlier "wp-content/themes/myawesomewebsite/functions.php"
- Copy the following code into the file (yep, that's PHP ... don't worry, you don't need to fully understand PHP to get this going, trust me!):
<?php
//* Code goes here
Inherit Parent Styles
- DON'T use the @import method ... (this is the one thing I don't like about the article, this is the old way of doing things so in my humble opinion, why mention it at all?!)
- DO use the wp_enqueue_style() method ... copy this code into your functions.php file (underneath the other bits we just pasted):
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
Upload Theme
- NB: This is a variation of Nick's "Activate Your Theme" step
- Zip your Theme folder, eg, "myawesomewebsite"
- Login to WordPress
- Click on Themes
- Click on Add New and upload your zip file
- NB: The parent theme must already be installed
- Activate your child theme
