Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I observed the inside the wp_head function in the source links of every .css, .js files a ?ver=1 (or other number based on the file's/library version) is added. How can I overwrite them, to remove them?

This issue I think is causing problems on the cache manifest part.

share|improve this question

2 Answers 2

up vote 7 down vote accepted

You can hook into style_loader_src and script_loader_src and run remove_query_arg( 'ver', $url ) on the URL:

/* Plugin Name: Remove version parameter for scripts and styles */

add_filter( 'style_loader_src', 't5_remove_version' );
add_filter( 'script_loader_src', 't5_remove_version' );

function t5_remove_version( $url )
    return remove_query_arg( 'ver', $url );

Without this plugin:

enter image description here

After plugin activation:

enter image description here

There is one case where that will fail: When someone didn’t use the script/style API, but added a hard coded string to the header.

share|improve this answer
Thank you very much. But this plugin is not removing the versions :) –  Grávuj Miklós Henrich Apr 18 '13 at 15:29
It does, I used it before. –  toscho Apr 18 '13 at 15:31
Yep, works for me. What's not working for you @GrávujMiklósHenrich? –  dalbaeb Apr 18 '13 at 15:31
Yes id does now. Sorry. I think the cache was. Can this be done also reversed? I mean leaving the version there but writing them also for the cache manifest files? Should i open another question for this? :) –  Grávuj Miklós Henrich Apr 18 '13 at 15:36
@GrávujMiklósHenrich Yes, I think that would be an interesting separate question. :) –  toscho Apr 18 '13 at 15:37

This worked for me when I still had to load a stylesheet from Google Fonts.

add_filter( 'script_loader_src', 'wpse130419_remove_script_version', 15, 1 );
add_filter( 'style_loader_src',  'wpse130419_remove_script_version', 15, 1 );
function wpse130419_remove_script_version( $src ) {

    $url = explode( '?', $src );

    if ( $url[0] === 'http://fonts.googleapis.com/css' ) :
        $version = explode( '&ver=', $url[1] );
        $url[1]  = $version[0];

    return ( $url[0] === 'http://fonts.googleapis.com/css' ) 
        ? "{$url[0]}?{$url[1]}"
        : $url[0]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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