0

I am modifying a WordPress theme, but the problem is every time I edit my CSS file via FileZilla and upload it to the server, the CSS file doesn't get updated immediately after browser refresh and it's very frustrating.

I get the idea that the CSS ver tag is helping browser not to cache old CSS files, but for the temporary purpose, I would like to disable it.

Can you guys give me a hint, how the code of style.css?ver=1.0.0 tag command might look like? So that I can reverse engineer it and modify it my self or remove it completely.

2

You're facing browser caching problem and it's not because of ver. Every time you update your CSS or JS files you should hard refresh your browser using Ctrl + Shift + R or you can change the ver value. If the default ver is ver=1.0.0 then update the ver to ver=1.0.1. The point is, change the ver value to something you didn't set before.

Most of the time the ver value comes from theme version. So you can try updating the Version parameter in style.css or find a theme version constant and update the value if there's any.

And if you still need to remove ver then add the following code in your functions.php and ver will be removed automatically -

add_filter( 'style_loader_src', function( $src, $handle ) {
    // If you know the handle
    // if ( 'your-css-handle' === $handle ) {
    //  return remove_query_arg( 'ver', $src );
    // }
    // return $src;
    return remove_query_arg( 'ver', $src );
}, 10, 2 );
0

Have you tried finding the solution enough, there is already many thread for your solution. How to remove version from css

To simplify check this.

add_filter( 'style_loader_src',  'sdt_remove_ver_css_js', 9999, 2 );

function sdt_remove_ver_css_js( $src, $handle ) 
{
$handles_with_version = [ 'style' ]; // <-- Adjust to your needs!

if ( strpos( $src, 'ver=' ) && ! in_array( $handle, $handles_with_version, true ) )
    $src = remove_query_arg( 'ver', $src );

return $src;
}

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