How can I instruct wordpress to use a filename other than 'styles.css' for my main stylesheet - for example, styles-1.css? I'd like to do this for versioning and caching purposes.
This will load your alternative stylesheet as the page's stylesheet and completely ignore the regular
This may be inappropriate, please let me know if I missed something.
The fourth argument to
Requires that your
This allows you to push long expiry headers with your CSS file, and force clients to download a new file by updating the version number. WP will append "?ver=N" to the URL of your CSS file.
Drop this in your theme's functions.php file:
EAMann is correct, you don't have to use the
For versioning the style sheet and other files in your theme you can add this to your functions.php file
And then when you make the link to your style sheet you can do this.
This way you don't have to manually update the version number, anytime the file is updated on the server the version will automatically change to that UNIX timestamp
Well, you could simply use
Then when you upgrade a version, just edit it to be:
As for saving versions, have you considered using a Subversion, or git? Then you can have a complete track record of your stylesheet. It's possible I'm not fully understanding the full reasons for your versioning.
Note, that you should not use querystrings for file versioning (proxys do not cache them).
A better way would be to version the filenames like by adding a number like
So my approach is the following:
Apache htaccess redirects
(You usually have to enable it first, by uncommenting the lines)
I wanted to automatically use the version of my theme for the stylesheet, so I came up with the following:
You can add the following to your themes functions.php:
Note, that I provided
This outputs a stylesheet like the following for Version 1.0.2 of your theme:
After I change my theme to Version 2.0.0 in my style.css it would output the following:
Take care, that if you just strip the dots of the version like I did you may get problems with theme version like 1.2.23 and 1.22.3, as they both result in a dotless version of 1223.
A better way would be to take that into account in the .htaccess file. Eg you could allow underscores between the numbers and could replace the dots with them.
This is untested, but should work:
I'm not sure if this has changed for WP3, so I'm not wholly sure, but one way is to edit the relevant php file directly (I don't know if it can be done from within the Dashboard/Admin pages):
And open up
To add a 'version' to the linked stylesheet (assuming you want it to be something like:
This is kind of inelegant, though, so if there's a better way I'd love to hear it myself =)
I just re-read your question...
To use a different stylesheet
(Basically removing the
I know that this thread is rather old by now. But in case someone needs a quick solution. There is a plugin called Versions which handles versioning of stylesheets and scripts automatically. Get it at: http://wordpress.org/extend/plugins/versions/