0
votes

i've created a child theme from the nightingale theme but when I try to change a propetry in nigthingale-child/style.css it doesn't apply. For instance I've tried to change background-color of the body or display none for h1 markup just to see whether my child theme style.css works but nothing happens.

I've followed all steps for creating a child theme: -new folder nightingale-child -inside this foder I've added two files : function.php & style.css here is my style.css :

/*
 Theme Name: nightingale-child
 Theme URI:    http://example.com/twenty-fifteen-child/
 Description:  nightingale Child Theme
 Author:       John Doe
 Author URI:   http://example.com
 Template:     nightingale
 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:  nightingalechild
*/

a {
color: red;
}


and here is my function.php:

<?php 
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );

function enqueue_parent_styles() {
   wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}

Does anybody know what's wrong with my nightingale-child theme ?

1

1 Answers

0
votes

Your function is loading the PARENT theme CSS. You need to change a couple things to load the CHILD CSS:

<?php 
// Let's change this to `enqueue_child_styles` so it's clearer.
add_action( 'wp_enqueue_scripts', 'enqueue_child_styles' );

// Now the function
function enqueue_child_styles() {
    // Rename the hook to child-style
   wp_enqueue_style( 'child-style', get_stylesheet_directory_uri().'/style.css' );
}

In this instance, you want to use get_stylesheet_directory_uri() since get_template_directory_uri() always points to the PARENT theme, where as get_stylesheet_directory_uri() points to the CHILD theme.