I'm attempting to modify a WordPress theme so that it appends a version number to a particular stylesheet. This is all done on a local development machine, tested on a staging server, too, for good measure. Following the instructions here:
https://www.mojowill.com/developer/get-your-wordpress-css-changes-noticed-immediately/, I added filemtime( get_template_directory() . '/css/main.css' )
into the arguments passed through wp_register_style
From:
wp_register_style('style', get_template_directory_uri() . '/css/style.css', array(), '', 'all');
to
wp_register_style('style', get_template_directory_uri() . '/css/style.css', array(), 'filemtime( get_template_directory_uri() . '/css/style.css'', 'all');
No soap. Viewing the source of the rendered page, I see the stylesheet link has no version appended to it.
I tried pulling the filemtime
function out of the $ver
slot, and replacing it with a static value like 1.0, and that didn't work, either. Finally, I skipped the $ver
argument, and changed the path to a versioned file, like so:
wp_register_style('style', get_template_directory_uri() . '/css/style.css?ver=1.0', array(), '', 'all');
Still nothing. Why would WordPress refuse to acknowledge these updates? No server-side caching or plugins that I could imagine would influence this process. Is there something very simple I'm missing?
Thanks much
James
edit: Here's the entire relevant code block.
function minikit_register_js_and_css() {
if (!is_admin()) {
wp_register_style('style', get_template_directory_uri() . '/css/style.css?ver=1.1', array(), '', 'all');
wp_enqueue_style('style');
}
}