Force WordPress theme CSS changes immediately
Theme authors: if you’ve been tweaking a WordPress site’s CSS file, the changes you’ve made usually don’t immediately show up for the blog visitors without a forced refresh. The reason: web browsers usually keep cached copies of site files. Mark Jaquith has a neat fix that allows you to grab the latest version of the CSS file and override the cached one automatically.
Just use this line of code in your header.php file:
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/style.css?v=<?php echo filemtime(TEMPLATEPATH . '/style.css'); ?>" type="text/css" media="screen, projection" />This automatically updates the
?v=part every time you modify the file. Boom. Now everyone instantly sees your changes.
This should also work for other files like your Javascript files.
Related Posts
- Previous post: Designing for WordPress screencast series
- Next post: WordPress Plugin: A Year Before
2 Comments
-
links for 2009-05-05 en newdisco Said,
May 6, 2009 @ 10:14 am
[...] Force WordPress theme CSS changes immediately | WordPress Philippines Como forzar la actualización de CSS cuando haces cambios en un theme. (tags: wordpress hack howto css theme template) Archivado en: | Search [...]
-
Edward Palomo Said,
June 17, 2009 @ 9:41 pm
This is what I’m looking for… since many of my blog’s visitors don’t know the word cache…LOL
Edward Palomo´s last blog post: My struggle to get it right: a novice web designer’s dilemma over browser compatibility issues
RSS feed for comments on this post · TrackBack URI



