Force iPhone CSS Update

OMFG. What a mess trying to force an iPhone CSS update while developing on a new site that needed some specific iPhone CSS tweaks. Banging my head against the desk trying to get just a simple forced CSS update to kick in. There’s always the change the name of the CSS file method, but that also makes me want to bang my head in.

The functions.php code for Genesis child themes

Here it is in all it’s glory. This is what I use to modify my Genesis child theme functions.php file so it forces CSS updates when EVER they are made. In a nutshell, this bit of code appends a version id equal to the last file timestamp on your style.css file. Now I would suggest that you could remove it once you’re done developing and testing as there’s no need for that call when you’re finally happy with the CSS. This website was still in tweaking stages and driving me nuts so HAD to make sure we were getting the most recent updates.

Add this to your Genesis child theme functions.php file…

add_filter('stylesheet_uri','wpi_stylesheet_uri',10,2);

/**
* wpi_stylesheet_uri
* overwrite default theme stylesheet uri
* filter stylesheet_uri
* @see get_stylesheet_uri()
*/
function wpi_stylesheet_uri($stylesheet_uri, $stylesheet_dir_uri){
return $stylesheet_dir_uri.'/style.css?ver=' . filemtime( get_stylesheet_directory() . '/style.css');
}

Author: Eric Erickson

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *