Force browser to load CSS & JS changes

// Version CSS file in a theme wp_enqueue_style( 'theme-styles', get_stylesheet_directory_uri() . '/style.css', array(), filemtime( get_stylesheet_directory() . '/style.css' ) ); // Version JS file in a theme wp_enqueue_script( 'theme-scripts', get_stylesheet_directory_uri() . '/js/scripts.js', array(), filemtime( get_stylesheet_directory() . '/js/scripts.js' ) );
When using a child theme and the css is being outputed the proper way then the wp_enqueue function should be on functions.php.

Adding the timestamp at the end of the style.css can be accomplished like shown on this snippet. Neat!

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.