Skip to content

Instantly share code, notes, and snippets.

@royce002
Created December 1, 2017 18:43
Show Gist options
  • Save royce002/7554295e87815c1ffdfcfdbb44bb3535 to your computer and use it in GitHub Desktop.
Save royce002/7554295e87815c1ffdfcfdbb44bb3535 to your computer and use it in GitHub Desktop.
Enqueue Scripts and styles with timestamp versioning for functions.php in WordPress
/**
* Enqueue Styles & Scripts w/ a hook
*/
function enqueue_styles_scripts_versioning() {
wp_enqueue_style('main-styles', get_template_directory_uri() . '/css/style.css', array(), filemtime(get_template_directory() . '/css/style.css'), false);
wp_enqueue_script( 'main-styles', get_template_directory_uri() . '/js/example.js', array(), filemtime(get_template_directory() . '/js/example.js'), true );
}
add_action( 'wp_enqueue_scripts', 'enqueue_styles_scripts_versioning' );
@oxwebdevelopment
Copy link

Awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment