Skip to content

Instantly share code, notes, and snippets.

@norewp
Created September 13, 2017 07:36
Show Gist options
  • Save norewp/1fd8913eec61e8a36dc14cd3aa3dfab6 to your computer and use it in GitHub Desktop.
Save norewp/1fd8913eec61e8a36dc14cd3aa3dfab6 to your computer and use it in GitHub Desktop.
Enqueue child theme style immediately after parent
<?php
function themename_scripts() {
global $themename_version; // This should be defined early on
$parent_style = 'parent-style'; // This is 'parent-style' for your theme.
$child_style = 'child-style';
//wp_enqueue_style( 'actions-style', get_template_directory_uri() . '/style.css', '', $themename_version );
if ( wp_get_theme()->get('Name') != 'ThemeName' ) {
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css', array(), $themename_version );
wp_enqueue_style( $child_style, get_stylesheet_directory_uri() . '/style.css', array( $parent_style ), $themename_version );
} else {
wp_enqueue_style( $parent_style, get_stylesheet_uri(), array(), $themename_version );
}
}
add_action( 'wp_enqueue_scripts', 'themename_scripts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment