Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Jared Codling
Jared Codling
810 Points

How do I turn off "?ver=" on my CSS so it stops caching in WordPress - what purpose does it serve?

I'm having issues with caching; my style.css inside my child theme isn't updating on the site, because it says ?ver=2.2.2 on the end of it. I'm using Genesis, but have had this issue with other sites using other themes.

1 Answer

Jared Codling
Jared Codling
810 Points

I used the following in my functions.php and it worked:

// Remove WP Version From Styles    
add_filter( 'style_loader_src', 'sdt_remove_ver_css_js', 9999 );
// Remove WP Version From Scripts
add_filter( 'script_loader_src', 'sdt_remove_ver_css_js', 9999 );

// Function to remove version numbers
function sdt_remove_ver_css_js( $src ) {
    if ( strpos( $src, 'ver=' ) )
        $src = remove_query_arg( 'ver', $src );
    return $src;
}