Hi folks, I haven’t written any tutorials for a while, I’m waiting on Genesis 1.8 to finish my Genesis Explained series because there are some changes coming to the admin system that would render most of what I said moot.
In the interim, I wanted to get some quick tips out there. Little tricks I use on my site or when developing for clients.
One thing that gets really annoying is cached style sheets. They are a good thing and I would never want to disable them, but if I make a change on my site, like the Child Theme Matrix, and a user has a cached version of my style sheet, things won’t look right. Likewise, when I developing for clients and make a change I want them to see, they won’t see it. The end user can do a hard refresh (ctrl+f5 on the PC) but that’s asking a lot, especially for changes on my site.
That’s why I version my style sheet. The code is really simple and it lets me update the style sheet the world sees when they visit my site. Right now this is what it looks like in my functions.php file
remove_action('genesis_meta', 'genesis_load_stylesheet'); add_action('genesis_meta', 'ntg_load_stylesheet'); /** * Loads Versions Style Sheet * * @uses wp_enqueue_style() * @author Nick the Geek * */ function ntg_load_stylesheet() { wp_enqueue_style( 'ntg-style', get_bloginfo('stylesheet_url'), array(), '1.0.1.4', 'screen' ); }
If I make a CSS change I need to push to the world, I can change “1.0.1.4” to “1.0.1.5”
Hope this helps.
Eric says
Any idea on when 1.8 is being released?
Thanks for the articles they have helped me a TON.
nickthegeek says
Genesis 1.8 should be coming out VERY soon. The last bits and bobs are being taken care of then it will be released as a beta for field testing.
Dave Tasker says
On a slightly different tack Nick…
I maintain a couple of themes for about 20 departments in our School, and short of hosting them all on a WordPress network it would be really cool if I could alert administrators through their WordPress Update screens when I updated the theme. Is there any way I can do this without hosting the themes on WordPress.org?
PLease forgive me if this is an inappropriate place to post this question!
Thanks for your posts btw – really enjoy reading them 🙂
JPry says
Hey Nick,
Thanks for sharing this. I remember when you first posted it months ago, and I just finally came back to it and implemented it myself. I made a slight change to your code using the new WP_Theme class that came with WordPress 3.4, so that your version number only has to exist in one place: the style.css file.
Check it out: https://gist.github.com/2991153