How to break CSS cache in WordPress

- Resources, Tips, Tutorials, Lettering

By default, the wp_enqueue_style() function will put whatever version of WordPress that you currently have installed behind your CSS call like this:

<link rel='stylesheet'  href='' type='text/css' media='all' />

Grab the theme version from your style.css file:

$theme = wp_get_theme();
define(‘THEME_VERSION’, $theme->Version);

Pass it as the 3rd parameter in your wp_enqueue_style() function in your functions.php:

wp_enqueue_style(‘main’, get_template_directory_uri() .’/css/main.css’, array(), THEME_VERSION);

If your style.css file has “Version: 1.0” in the top commment, it will now output this:

<link rel='stylesheet' href='' type='text/css' media='all' />

Please follow and like us:

January 6, 2022 by Jerad

Tagged: , , ,

Reply or Comment

Your email address will not be published. Required fields are marked *


Enjoy this blog? Please spread the word :)