I have created a child theme from the Casper WP theme. It is called casper-child, the Casper parent theme is in a folder called "casper-master". Here is my child style.css file that is being read correctly (the background color does change to pink).
/*
Theme Name: Casper Child
Description: Child theme for Casper theme
Author: Grant
Template: casper-master
*/
body { background-color: pink; }
My problem is that my functions.php file is not being read/working.
My functions.php for my child theme is located here: /wp-content/themes/casper-child/functions.php
The parents functions.php file is at /wp-content/themes/casper-master/functions.php
The code I have in my child's functions.php is:
<?php
add_action( 'wp_enqueue_scripts', 'my_child_theme_scripts' );
function my_child_theme_scripts() {
wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
}
The parent theme is still not being loaded. Any ideas why? I can't seem to get anything to work in the functions.php file, no custom functions with redirects or anything. It feels like the file is not being read.
Most of the Wordpress documentation has add_action
after the function, not sure if this will make a difference at all.
Also in your example there is no closing ?>
Turns out the Casper theme needs a specific Casper Child Theme in order to create a child theme. I found it here: http://hackersome.com/p/lacymorrow/casper
I am having a issue installing this child theme to my web host. The dash tells me this as the child theme is not even selectable.
I created my child theme on my local machine. Therefore I know it is working on my local environment. I did not change the core,only css styles and moved the navigation.
Local development running 4.1.5, host running 4.2.2
Under the documentation on the top of the style.css in the -child theme capitalization creates issues on the web server, not my local environment. For reference I am using MAMP.
For some reason the theme would not install, but then it would install sometimes. I could never activate the theme as I would always get the 'Parent theme is not installed.' It was the entire time.
I upgraded Wordpress on my local environment to the same on the host from 4.1.5 to 4.2.2. The result is that my local environment had no issues. I had the same problem.
It came to changing the capitalism in the style.css in the child theme:
From
/**
Theme Name:Casper-child
Template:Casper
Author: Todd
version: 0.1
*/
To
/**
Theme Name:Casper-child
Template:casper
Author: Todd
version: 0.2
*/
Under Template:Casper had to be lowercased for the web host. Weird and tedious problem. Wasted few hours to figure this out, hope this helps someone :)