Here’s the new staging url
7c8.96a.myftpupload.com
My limited understanding of php prevents me from knowing where and how and where to use code in order to reference additional files ( to the css) in my child theme.
If you want to do some changes in CSS, you can just put your version of changed CSS in child theme’s style.css, but if you want to include the whole new CSS file then the file will be called in child theme’s function.php
Take a careful look at this Child Theme codex page, lot of info there.
https://codex.wordpress.org/Child_Themes
My theme has altered feature, home, and sidebar php files. So I understand that I should put those altered files in my child folder and references them?
For theme template (PHP) file, just drop it into child theme folder and WP will automatically use that instead of the ones in parents, there is no need to do anything else.
Thank you but this is extremely confusing to me!
Can you tell me if the child function.php code below correct?
FYI EarthlyTouch is the parent theme Child is the child. For some reason there is a style sheet that is blank but just pulls in the green-style.css
[ Moderator note: Code fixed, please wrap code in backticks or use the code button. ]
/*
Theme Name: Child
Theme URI: http://www.elegantthemes.com/
Author: http://www.boplinger.com
Template:EarthlyTouch
Version: 0.1
*/
@import url("../EarthlyTouch-child/style-Green.css");
<?php
/**
* Enqueues child theme stylesheet, loading first the parent theme stylesheet.
*/
function EarthlyTouch_custom_enqueue_child_theme_styles() {
wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style-Green.css' );
}
add_action( 'wp_enqueue_scripts', 'EarthlyTouch_custom_enqueue_child_theme_styles' );
If you use @import method in child theme’s style.css, then there is no need to enqueue style in function.php, don’t do both, just pick one.
The proper method is to not use @import in child theme’s style.css, so your stater child style.css should be just the header info. And do the enqueue in child’s function.php
We need to get all the working parent stylesheets, so the style-Green.css might not be just one that needed to enqueue, it’s a matter of understanding how parent theme works.
Thanks Paul,
I see. But when I uploaded a function.php in the child folder I got an error. Anyway I gave up and used a plugin.
I did not build this old theme but inherited all it’s idiosyncrasies. Because the theme had hard coded links in the header I choose an enqueue method for that scenario. It’s interesting to see what it generated as a result.
This is in the style.css file:
/*
Theme Name: Child
Theme URI: http://www.elegantwordpressthemes.com
Template: EarthlyTouch
Author: http://www.boplinger.com
Version: 0.1.1432608545
Updated: 2015-05-26 02:49:05
*/
@charset “UTF-8”;
And this is in the function.php:
<?php
// Exit if accessed directly
if ( !defined( ‘ABSPATH’ ) ) exit;
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED – Do not modify or remove comment markers above or below:
if ( !function_exists( ‘chld_thm_cfg_parent_css’ ) ):
function chld_thm_cfg_parent_css() {
wp_enqueue_style( ‘chld_thm_cfg_parent’, trailingslashit( get_template_directory_uri() ) . ‘style.css’ );
wp_enqueue_style( ‘chld_thm_cfg_ext1’, trailingslashit( get_theme_root_uri() ) . ‘EarthlyTouch-child/style-Green.css’ );
wp_enqueue_style( ‘chld_thm_cfg_ext2’, trailingslashit( get_theme_root_uri() ) . ‘EarthlyTouch-child/style-Green.css’ );
}
endif;
add_action( ‘wp_enqueue_scripts’, ‘chld_thm_cfg_parent_css’ );
if ( !function_exists( ‘chld_thm_cfg_child_css’ ) ):
function chld_thm_cfg_child_css() {
wp_enqueue_style( ‘chld_thm_cfg_child’, get_stylesheet_uri() );
}
endif;
add_action( ‘wp_enqueue_scripts’, ‘chld_thm_cfg_child_css’, 999 );
// END ENQUEUE PARENT ACTION