Skip to content

Instantly share code, notes, and snippets.

@jopfre
Created June 23, 2016 12:52
Show Gist options
  • Save jopfre/ffd0153015a791ee25dc14e6cec825f6 to your computer and use it in GitHub Desktop.
Save jopfre/ffd0153015a791ee25dc14e6cec825f6 to your computer and use it in GitHub Desktop.
Add Timestamp to WordPress Child Theme Stylesheet to invalidate cache
function add_timestamp_to_childtheme_stylesheet() {
wp_dequeue_style( 'style' );
wp_deregister_style( 'style' );
wp_enqueue_style('style', get_stylesheet_uri().'?'.filemtime(get_stylesheet_directory().'/style.css'), array(), null);
}
add_action( 'wp_print_styles', 'add_timestamp_to_childtheme_stylesheet' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment