Wordpress - remove the version number from styles and scripts


/ Published in: PHP
Save to your folder(s)

Put it in functions.php


Copy this code and paste it in your HTML
  1. //Removes version number from scripts and styles
  2. function remove_src_version ( $src ) {
  3.  
  4. global $wp_version;
  5.  
  6. $version_str = '?ver='.$wp_version;
  7. $version_str_offset = strlen( $src ) - strlen( $version_str );
  8.  
  9. if( substr( $src, $version_str_offset ) == $version_str ){
  10. return substr( $src, 0, $version_str_offset );
  11. } else{
  12. return $src;
  13. }
  14. }
  15. add_filter( 'script_loader_src', 'remove_src_version' );
  16. add_filter( 'style_loader_src', 'remove_src_version' );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.