Saturday, October 14, 2017

Remove version string (.css?v=2.0.1) from any css and javascript url in wordPress

Here is the code


// Remove query string  from static files

function removeJsCssVersionString( $src ) {
 if( strpos( $src, '?ver=' ) )
 $src = remove_query_arg( 'ver', $src );
 return $src;
}
add_filter( 'style_loader_src', 'removeJsCssVersionString', 10, 2 );
add_filter( 'script_loader_src', 'removeJsCssVersionString', 10, 2 );

No comments:

Post a Comment