Skip to content

Instantly share code, notes, and snippets.

@Drivingralle
Created December 1, 2016 15:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drivingralle/83a5387d69b72595b554dfaea92a1c6b to your computer and use it in GitHub Desktop.
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
<?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