This question already has an answer here:

I am trying to remove the WordPress version number from the file extensions for security purposes. Some of the enqueued files include the WordPress version number on the end of them, which can be seen from the inspector. For example:

<link rel="stylesheet" id="admin-bar-css" href="http://sitename.com/wp-includes/css/admin-bar.min.css?ver=3.8.1" type="text/css" media="all">

As you can see, ver=3.8.1 was apended. I've come across a few filters that remove the WordPress version number from the header and footer etc, but not from the included files. That filter looks like:

function remove_version() {
    return '';
 }
add_filter('the_generator', 'remove_version');

But that does not remove the version number from linked files. Does any one know of a way to remove this version number??

Thanks

marked as duplicate by fuxia Feb 3 '14 at 15:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 12 down vote accepted

After further Googling I was able to come across a site that explains how to achieve this.

http://www.virendrachandak.com/techtalk/how-to-remove-wordpress-version-parameter-from-js-and-css-files/

The second function on the page is quite helpful. This looks for "ver=" and checks that it matches the WordPress version number and then removes it. The first function on the page removes all version numbers from all files.

The function that achieved the results looks like:

// remove wp version param from any enqueued scripts
function vc_remove_wp_ver_css_js( $src ) {
    if ( strpos( $src, 'ver=' . get_bloginfo( 'version' ) ) )
        $src = remove_query_arg( 'ver', $src );
    return $src;
}
add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
  • 2
    This answer came first when Googling "wordpress no version script" and I would like to add that setting the fourth argument to null in the wp_enqueue_script function also removes the WordPress version number for any scripts included using that function (e.g. in the functions.php file). The answers here already seem to remove the version number from all script and css files which is a slightly different effect since passing a null argument as the 4th parameter just affects one script of course. – wclear Jan 3 '17 at 17:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.