Skip to content

Instantly share code, notes, and snippets.

@michaelbragg
Created September 7, 2015 07:55
Show Gist options
  • Save michaelbragg/7699c6b41f4cfe0920fa to your computer and use it in GitHub Desktop.
Save michaelbragg/7699c6b41f4cfe0920fa to your computer and use it in GitHub Desktop.
Base WordPress child theme functions file to load in both styles sheets from parent and child.
<?php
/**
* Child functions and definitions.
*
* @link https://codex.wordpress.org/Functions_File_Explained
*
* @package child
*/
if ( ! function_exists( 'child' ) ) :
add_action( 'wp_enqueue_scripts', 'enqueue_styles' );
function enqueue_styles() {
// Check that we are a child theme.
if ( is_child_theme() ) {
// Load parent CSS. Noting the use of `get_template_directory_uri()` to get the parent themes path.
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css', array(), '1.0.0' );
}
// Load our child's CSS. Remembering to add our parent file as a dependancy to be loaded before.
wp_enqueue_style( 'child-style', get_stylesheet_uri(), array('parent-style'), '1.0.0' );
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment