Skip to content

Instantly share code, notes, and snippets.

@montchr
Last active December 21, 2015 11:28
Show Gist options
  • Save montchr/6298823 to your computer and use it in GitHub Desktop.
Save montchr/6298823 to your computer and use it in GitHub Desktop.
Enqueuing styles for WP child theme

Parent

Line 9 of lib/enqueue-sass.php:

Currently:

wp_register_style( 'esemci-stylesheet', get_template_directory_uri() . '/css/style.css', array(), '', 'all' );

Change to:

wp_register_style( 'esemci-stylesheet', get_stylesheet_directory_uri() . '/css/style.css', array(), '', 'all' );

Child

  • Mirror the directory structure for clarity's sake. I.E. /scss/ and /css/.
  • Create functions.php.

Put something like this in functions.php:

<?php
    add_action( 'wp_enqueue_scripts', 'prefix_add_my_stylesheet' );

	function prefix_add_my_stylesheet() {
		wp_register_style( 'prefix-style', get_stylesheet_directory_uri() . '/css/style.css' );
		wp_register_style( 'esemci-stylesheet', get_template_directory_uri() . '/css/style.css' );

		wp_enqueue_style( 'esemci-stylesheet' );
		wp_enqueue_style( 'prefix-style', false, array('esemci-stylesheet') );
	}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment