Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WordPress | Enqueue scripts/styles automaticly using right version number from parent-/child-theme
* 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
You can’t perform that action at this time.