Have you ever made changes to your WordPress theme’s CSS file, then asked your client to have a look only to have them say they don’t see the change? Often it’s because their browser has cached the old stylesheet. So you ask them to empty their browser cache, or press f5 or command+R, and you hear silence on the phone.
First, I found this post by Mark Jaquith: Force CSS changes to “go live” immediately. This worked great for a long time, but now wp_enqueue_style() is preferred, so that solution no longer worked.
Here’s what I do now to enqueue a style sheet with a timestamp:
function themeslug_enqueue_style(){ wp_enqueue_style( 'style', get_stylesheet_directory_uri().'/style.css', array(), filemtime( get_stylesheet_directory().'/style.css' ) ); } add_action('wp_enqueue_scripts','themeslug_enqueue_style');
The post Force Browser to Use Latest WordPress CSS appeared first on Swamp-Side Studio.