Skip to content

Instantly share code, notes, and snippets.

@robneu
Last active December 17, 2015 23:08
Show Gist options
  • Save robneu/5686688 to your computer and use it in GitHub Desktop.
Save robneu/5686688 to your computer and use it in GitHub Desktop.
Make cache busting easier in Genesis by enqueueing a genesis child theme stylesheet with the child theme version appended.
<?php
// Remove the default Genesis child theme CSS
remove_action( 'genesis_meta', 'genesis_load_stylesheet' );
add_action( 'wp_enqueue_scripts', 'prefix_load_stylesheet' );
/**
* Get the current child theme version
* and use it to bust the cache by appending
* it to the CSS output.
*
* @author FAT Media
* @link http://youneedfat.com
*/
function prefix_load_stylesheet() {
// Get the theme info.
$my_theme = wp_get_theme();
$theme_uri = get_stylesheet_directory_uri();
$theme_version = $my_theme->Version;
// Enqueue the stylesheet.
wp_enqueue_style( 'prefix-styles', $theme_uri . '/style.css', array(), $theme_version );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment