Last active
December 17, 2015 23:08
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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