Skip to content

Instantly share code, notes, and snippets.

@richaber

richaber/example-1-result.html Secret

Last active Mar 20, 2020
Embed
What would you like to do?
Cache Busting
<link rel='stylesheet' id='my-custom-style-css' href='https://example.com/wp-content/themes/mycustomtheme/css/customstyle.css?ver=1.0.0' type='text/css' media='all' />
<link rel='stylesheet' id='my-custom-style-css' href='https://example.com/wp-content/themes/mycustomtheme/css/customstyle.css?ver=1584639960' type='text/css' media='all' />
<?php
/**
* Example stylesheet enqueue with manually maintained version number.
*/
/**
* Enqueue our custom stylesheet.
*/
function my_enqueue() {
/**
* Enqueue our custom theme stylesheet.
*
* @link https://developer.wordpress.org/reference/functions/wp_enqueue_style/
*/
wp_enqueue_style(
'my-custom-style', // handle
get_stylesheet_directory_uri() . '/css/customstyle.css', // src
[], // deps
'1.0.0' // ver
);
}
add_action( 'wp_enqueue_scripts', 'my_enqueue' );
<?php
/**
* Example stylesheet enqueue with automagic version number.
*/
/**
* Enqueue our custom stylesheet.
*/
function my_enqueue() {
/**
* Enqueue our custom theme stylesheet.
*
* @link https://developer.wordpress.org/reference/functions/wp_enqueue_style/
*/
wp_enqueue_style(
'my-custom-style', // handle
get_stylesheet_directory_uri() . '/css/customstyle.css', // src
[], // deps
filemtime( get_stylesheet_directory() . '/css/customstyle.css' ) // ver
);
}
add_action( 'wp_enqueue_scripts', 'my_enqueue' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.