Last active
June 4, 2021 19:22
-
-
Save tigredanky/9f81a9e84bdba023a0b87a8a3ff3e834 to your computer and use it in GitHub Desktop.
WordPress Functions.php | Child Theme CSS Versioning for Testing
This file contains 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
<? | |
// 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