Last active
August 29, 2015 14:08
-
-
Save angelausy/e9c9c9abb47aa3c76525 to your computer and use it in GitHub Desktop.
Enqueue child-theme styles in parent theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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