0

I'm creating and installing a child theme for the first time. There are only a few edits to the style.css and one to the functions.php file. Do I need to copy the entire parent style.css into the child directory and then include my edits or do I just include my edits in the child style.css with no other code and the two files (parent and child) will be combined when installing? Likewise, since I'm changing the functions.php file in a couple spot (my edit and addition of the engueue), do I copy the whole functions.php file into the child theme directory or just include the edits in the child functions.php file?

2 Answers 2

0

You'll never have to copy anything from the parent theme to your child theme. In the case of CSS it would be wasteful, in the case of functions.php it will likely cause errors due to duplicated function names. If your parent theme is badly written it may not enqueue its own stylesheet when it's not the active theme and you may have to work around that, for example by enqueueing the parent theme's stylesheet manually in your child theme's functions.php:

add_action( 'wp_enqueue_scripts', 'wpse425666_enqueue_styles' );

function wpse425666_enqueue_styles() {
    wp_enqueue_style( 
        'your-theme-parent-style', 
        get_parent_theme_file_uri( 'style.css' )
    );
}

Note that this is just an example, we can't tell you whether this will be necessary because we don't know what your parent theme is and whether it's been coded properly to allow for child themes.

2
  • Thanks for your answer. Sorry, I omitted the parent theme. It is twentysixteen.
    – denewey
    Commented Jun 14 at 20:03
  • Since 2016 is a default theme you can probably assume it's child theme aware.
    – Chris Cox
    Commented Jun 14 at 20:08
0

You shouldn't copy content of style.css and functions.php from parent.

The functions.php file from the child theme will be loaded before the one from the parent theme. For a style.css , it depends on the theme. The parent theme may load both style files or just one from the active theme. You can read more here and here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.