Have you added a functions.php file to the child theme ?
Try enqueuing your child theme’s css in functions.php, but make sure you enqueue it after the parent theme’s css. This way everything that appears in the child theme’s css overrides what is inside the parent theme’s css.
Thread Starter
robmcp
(@robmcp)
I sort of wondered about that I don’t have a functions.php on the child theme (was unsure on this) I’ll add one. If I add one, will the parent theme functions.php carry out its processes, THEN any child theme functions.php processes ?
Your wording is not clear to me (inexperience)
Try enqueuing your child theme’s css in functions.php
Enqueue can you clarify the term?
Thanks.
Exactly, the parent theme functions.php will work just fine, all you need to put inside your child theme’s functions.php is this code here:
<?php
function my_child_theme_styles() {
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') );
}
add_action( 'wp_enqueue_scripts', 'my_child_theme_styles');
?>
After making the functions.php file it should work just fine.
Thread Starter
robmcp
(@robmcp)
Thank You kindly.
I reworded my search criteria and eventually found the Child themes Codex which I’m now reading.
Cheers for your time.
Thread Starter
robmcp
(@robmcp)
Further question.
After reading the Codex document and your answer I am unsure of the syntax to use on the Child Functions.php file.
Your code example.
<?php
function my_child_theme_styles() {
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’) );
}
add_action( ‘wp_enqueue_scripts’, ‘my_child_theme_styles’);
?>
If I am using a Parent theme of DIVI and a Child theme of baby-divi.
Could I trouble anyone to show me in the function above what the sytax would be for those names?
Thanks.
Thread Starter
robmcp
(@robmcp)
Think I’ve worked this out.
Thread Starter
robmcp
(@robmcp)
Nope, I lied, I got the syntax wrong, so any pointers would be appreciated.
When I try the amended supplied code example I got an unexpected identifier T_string error in line 5, that was because I had first of all spaces in the name, then “-” dashes, then I tried “_” underscores which removed the error but in the example I am still unsure of what parameter goes where.
My full attempt below
<?php
function my_child_theme_styles() {
wp_enqueue_style( ‘Parent_2017’, get_template_directory_uri().’/style.css’ );
wp_enqueue_style( ‘child_2017 ’, get_stylesheet_directory_uri().’/style.css’, array(‘parent_2017’) );
}
add_action( ‘wp_enqueue_scripts’, ‘my_child_theme_styles’);
?>
On the add action line, are the two supplied examples correct parameters?
OR should “my_child_theme_styles” be some other value / name?
My difficulty is that I am unsure what is a correct parameter and what is a tag that should be replaced with my named files.
Sorry for basic queries but we all start somewhere.
-
This reply was modified 9 years, 3 months ago by
robmcp.
In your child theme css did you mentioned correctly the template ? The code should work as it is.
Thread Starter
robmcp
(@robmcp)
Thanks for the help. It looks like it’s working, though I still need to do ssom more investigation as I see that the preferred method is not to use @import
Thanks for your time.
You don’t have to use @import in your css because wp_enqueue_style is doing it for you, you are just making your page load slower that way. No problem, if you have any questions, feel free to ask.