jcadima
7/19/2017 - 1:46 PM

Remove WP version number from styles and scripts

Remove WP version number from styles and scripts


<?php
//Removes version number from scripts and styles
function remove_src_version ( $src ) {
 
  global $wp_version;
 
  $version_str = '?ver='.$wp_version;
  $version_str_offset = strlen( $src ) - strlen( $version_str );
 
  if( substr( $src, $version_str_offset ) == $version_str ){
		return substr( $src, 0, $version_str_offset );
	} else{
		return $src;
	}
}
add_filter( 'script_loader_src', 'remove_src_version' );
add_filter( 'style_loader_src', 'remove_src_version' );