Skip to content

Instantly share code, notes, and snippets.

@gpbeer
Last active April 14, 2017 12:54
Show Gist options
  • Save gpbeer/d56b3b177d3431bd66a212a1773dfbab to your computer and use it in GitHub Desktop.
Save gpbeer/d56b3b177d3431bd66a212a1773dfbab to your computer and use it in GitHub Desktop.
Cache busting in wordpress wp_enqueue_style main stylesheet with Sass random
/**************************************************
* Enqueue theme scripts
***************************************************/
function enqueue_theme_scripts() {
// Will generate the main stylesheet with a random version everytime the style.scss file is compiled
// (http://www.b.....com/wp-content/themes/my-theme/style.css?ver=1.1.#{$version})
wp_enqueue_style( 'main-stylesheet', get_stylesheet_uri(), false, wp_get_theme()->get('Version') );
}
add_action( 'wp_enqueue_scripts', 'enqueue_theme_scripts' );
$version: "1.1."+random(100) ;
/*
Theme Name: My theme name
Author: German Pichardo
Author URI: german-pichardo.com
Version: #{$version}
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: german-pichardo.com
*/
body {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment