Skip to content

Instantly share code, notes, and snippets.

@coulterpeterson
Created April 28, 2021 19:06
Show Gist options
  • Save coulterpeterson/ab0cd729da0ea7b85752916db876295a to your computer and use it in GitHub Desktop.
Save coulterpeterson/ab0cd729da0ea7b85752916db876295a to your computer and use it in GitHub Desktop.
Magical Function that Prioritizes the Enqueued Child Stylesheet Over the Parent in #WordPress
<?php
// enqueue parent styles
function ns_enqueue_styles() {
// thanks https://nickschaeferhoff.com/wordpress-child-theme/
$parent_style = 'parent-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'ns_enqueue_styles' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment