Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Created February 23, 2012 13:21
Show Gist options
  • Save GaryJones/1892762 to your computer and use it in GitHub Desktop.
Save GaryJones/1892762 to your computer and use it in GitHub Desktop.
Cache bust the style.css reference in WordPress.
<?php
add_filter( 'stylesheet_uri', 'gmj_stylesheet_uri' );
/**
* Cache bust the style.css reference.
*
* Includes the file last modified time as a querystring.
*
* @author Gary Jones
* @link https://gist.github.com/1892762
*
* @param string $stylesheet_uri Existing URI to style.css.
*
* @return string Amended URI to style.css.
*/
function gmj_stylesheet_uri( $stylesheet_uri ) {
return add_query_arg( 'v', filemtime( get_stylesheet_directory() . '/style.css' ), $stylesheet_uri );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment