Skip to content

Instantly share code, notes, and snippets.

@tigredanky
Last active June 4, 2021 19:22
Show Gist options
  • Save tigredanky/9f81a9e84bdba023a0b87a8a3ff3e834 to your computer and use it in GitHub Desktop.
Save tigredanky/9f81a9e84bdba023a0b87a8a3ff3e834 to your computer and use it in GitHub Desktop.
WordPress Functions.php | Child Theme CSS Versioning for Testing
<?
// Found Here: https://generatepress.com/forums/topic/child-theme-style-css-version-string/
function _fix_child_css_version( $src ) {
$parts = explode( '?', $src );
if ( stristr( $parts[0], 'your-child-theme/style.css' ) ) {
$child_ver = filemtime( get_stylesheet_directory() . '/style.css' );
return $parts[0] . '?v=' . $child_ver;
}
else {
return $src;
}
}
add_filter( 'style_loader_src', '_fix_child_css_version', 15, 1 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment