Skip to content

Instantly share code, notes, and snippets.

@Inzman
Created September 5, 2019 12:17
Show Gist options
  • Select an option

  • Save Inzman/4b37ba375ec63d44ccacbcb5ffb64772 to your computer and use it in GitHub Desktop.

Select an option

Save Inzman/4b37ba375ec63d44ccacbcb5ffb64772 to your computer and use it in GitHub Desktop.
Wordpress - fix child CSS version cache
function _fix_child_css_version( $src ) {
$parts = explode( '?', $src );
if ( stristr( $parts[0], '-child/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