Skip to content

Instantly share code, notes, and snippets.

@rfmeier
Last active December 11, 2015 05: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 rfmeier/4550111 to your computer and use it in GitHub Desktop.
Save rfmeier/4550111 to your computer and use it in GitHub Desktop.
Including parent style.css file in a TwentyTwelve child theme.
<?php
/**
* Callback for WordPress 'wp_enqueue_scripts' action.
*
* This callback is executed before the parent theme (TwentyTwelve)
* 'wp_enqueue_scripts' callback is executed. This is due to the fact
* that the child theme functions.php is loaded before the parent functions.php
* file.
*
* This method avoids having the child theme style.css import within the css file.
*
* For more information just Google 'css @import problems'.
*/
function twentytwelve_child_wp_enqueue_scripts(){
/*
* A note on wp_register_style() and wp_enqueue_style().
* You must use wp_register_style() in order to change the source url if
* wp_register_style() or wp_enqueue_style() for the specified handle.
*
* Here you can either use wp_register_style() or wp_enqueue_style() and give
* source urls. I just prefer wp_register_style().
*/
wp_register_style( 'twentytwelve-style', get_template_directory_uri() . '/style.css' );
// Register the child (rfmeier) style.css url
wp_register_style( 'style', get_stylesheet_uri(), array( 'twentytwelve-style' ) );
// Enqueue parent and child styles
wp_enqueue_style( 'style' );
}
add_action( 'wp_enqueue_scripts', 'twentytwelve_child_wp_enqueue_scripts', 11 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment