Skip to content

Instantly share code, notes, and snippets.

@angelausy angelausy/functions.php

Last active Aug 29, 2015
Embed
What would you like to do?
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
You can’t perform that action at this time.