Enqueue child theme css
-
I’ve set up a child theme for Twenty Sixteen and it works fine except I can’t get it to recognize css that I put in the child theme’s styles.css file. To make any changes in css I have to use the customizer’s Additional CSS function. I’ve researched many articles and watched tutorial videos and pretty much everything I find contradicts what I find elsewhere. Some places say that in Twenty Sixteen it isn’t necessary to enqueue the child’s styles.css and others give an endless variety of ways to do it.
Here are the relevant lines from my functions file as currently in place:
// 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', array( 'genericons' ) ); } endif; add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 10 ); // END ENQUEUE PARENT ACTIONI can’t remember where I obtained that code. I’ve tried replacing it with the following, which is recommended in the Codex:
<?php add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); function my_theme_enqueue_styles() { $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme. 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 ), wp_get_theme()->get('Version') ); } ?>That doesn’t work either. Where am I going wrong?
The topic ‘Enqueue child theme css’ is closed to new replies.