Skip to content

Instantly share code, notes, and snippets.

@angelausy
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelausy/e9c9c9abb47aa3c76525 to your computer and use it in GitHub Desktop.
Save angelausy/e9c9c9abb47aa3c76525 to your computer and use it in GitHub Desktop.
Enqueue child-theme styles in parent theme
<?php
/*
* *********************************************************************************
* EDIT: see Justin Tadlock's tried and true method
* http://justintadlock.com/archives/2014/11/03/loading-parent-styles-for-child-themes
* *********************************************************************************
*/
// A more advanced child-theme author can write their own version (e.g. to enqueue other stylesheets).
if ( !function_exists('themename_child_scripts') ) {
function themename_child_scripts() {
/* check if active theme is child theme */
if ( is_child_theme() ) {
/* if child theme, load child theme's style.css, with parent theme stylesheet as dependency */
wp_enqueue_style( 'themename-child-style', get_stylesheet_uri(), array('themename-style') );
}
}
/* load child theme stylesheet last */
add_action('wp_enqueue_scripts', 'themename_child_scripts', PHP_INT_MAX);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment