huzze.net

rss feed


me and the voices in my head

Main menu

Skip to content
  • Home
  • Despre
  • Tips and Tricks
  • Contact
  • Random

Update that theme. NOW!

Posted on 07 October 2010 at 00:03 in code|Jump To Comments

If you like to tinker around with the style of your theme a lot like I do, you will probably like this article. Our aim is to force the new style.css file over the old one the users’ cache has. You can do this the dumb-dumb way, the hard way, or the easy way.

The dumb-dumb way is to ignore this issue and wait until the users’ caches expire. Not a very good idea if you ask me.

The hard way is to set some .htaccess expire headers. You can add rules for the CSS to expire every x hours, days, weeks, etc. but I thought we were trying to force the new CSS file right away 8-O .

This brings us to the easy way: tweaking the header.php file a bit! All you have to do is replace your usual style inclusion with a new one. The magic line is:

<link rel="stylesheet" type="text/css" href="<?php echo bloginfo('stylesheet_url'). '?' . filemtime( get_stylesheet_directory() . '/style.css'); ?>" />

After you update your header.php file you should see something like this when you view the source in your browser:

<link rel="stylesheet" type="text/css" href="http://huzze.net/wp-content/themes/huzze/style.css?1286398426" />
Yeah, the funky numbers after the question mark are the secret.

Simple as that. No more waiting, no more F5, no more nothing. Just a simple click on your “home” button and you will see the changes immediately! :-D


Tags: .htaccess, blog, cache, css, hack, trick, update, wordpress

« Mark external links with CSS3 attribute selectors|Animal cruelty »



Articole asemănătoare:

  1. Pages with no comments
  2. Downtime + Theme
  3. Enabling WordPress3 Menus

2 Comentarii la “Update that theme. NOW!” »

  1. Claudiu T says:
    09 October 2010 at 15:15

    No need to do so, if you use the WordPress built-in editor. I use it because I’m too lazy to use the ftp.

    Reply
    • Andrei says:
      09 October 2010 at 15:18

      I had some problems with the built-in editor on phpBB so I don’t use it :P

      Reply

Trackbacks/Pingbacks »

  1. Update that theme. NOW! - Ziarul toateBlogurile.ro says:
    07 October 2010 at 01:01

    [...] Update that theme. NOW! Thu Oct 07, 2010 0:03 am If you like to tinker around with the style of your theme a lot like I do, you will probably like this article. Our aim is to force the new style.css file over the old one the users’ cache has. You can do this the dumb-dumb way, the hard way, or the easy way. The [...] [...]

    Reply
Changed my mind, no more replying

Ia să te aud și pe tine:


 

email twitter fb gplus lastfm forrst


ULTIMELE CIRIPELI:

My Tweets

Prieteni:

Cristina
Andera
Florin
Andreea L.
'mnealui
Veve
Mariciu
Bogdan
Cuvinte Alese
Vlad Olteanu
More »

Copyright © 2010 - 2013 Huzze [dot] net
Proudly hosted with shophost.