Last updated on February 10, 2018
In this post i will show you how to remove the version parameter from scripts and stylesheets enqueued by WordPress’s wp_enqueue_script() and wp_enqueue_style() functions.
you can paste(put) this code in the function.php
(or)
Create a file in your plug-in folder called RemoveVersion.php(you can name whatever you like) put below code in it along with plug-in declaration comments. Then go to admin dashboard plugin area and then active the remove version plug-in.
That’s it, you can follow any one of the above methods.
add_filter( 'script_loader_src', 'remove_version' ); add_filter( 'style_loader_src', 'remove_version' ); function remove_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; }
Reference links
script_loader_src(): https://developer.wordpress.org/reference/hooks/script_loader_src/
wp_enqueue_script(): http://codex.wordpress.org/Function_Reference/wp_enqueue_script
wp_enqueue_style():http://codex.wordpress.org/Function_Reference/wp_enqueue_style
I hope you like this tutorial, don’t forget to share your views, comments, and suggestion via comments.