Created
April 28, 2021 19:06
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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