Created
December 1, 2016 15:06
-
-
Save Drivingralle/83a5387d69b72595b554dfaea92a1c6b to your computer and use it in GitHub Desktop.
WordPress | Enqueue scripts/styles automaticly using right version number from parent-/child-theme
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 and child theme style.css | |
*/ | |
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles', 20 ); | |
function my_theme_enqueue_styles() { | |
// Get the theme data | |
$my_theme = wp_get_theme(); | |
// Add parent theme styles | |
wp_enqueue_style( 'parent-theme', get_template_directory_uri() . '/style.css', array(), $my_theme->parent()->get( 'Version' ) ); | |
// Add child theme styles | |
wp_enqueue_style( 'child-theme', get_stylesheet_directory_uri() . '/style.css', array( 'parent-theme', ), $my_theme->get( 'Version' ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment