Last active
July 12, 2019 21:26
-
-
Save wasalwayshere/b65b3fa5d098d765696c0be7095172b5 to your computer and use it in GitHub Desktop.
Wordpress / Woocommerce child theme wp_enqueue_scripts with version refresh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Enqueue child theme css | |
// Put this snippet in your functions.php file | |
// CSS file location in example: wp-content/themes/[your-child-theme-dir]/css/child-style.css | |
// use filemtime() to clear version cache with each file update | |
add_action( 'wp_enqueue_scripts', 'custom_theme_stylesheets',99); | |
function custom_theme_stylesheets() { | |
wp_enqueue_style( 'custom-child-style', get_template_directory_uri() .'-child/css/child-style.css', array(), $ver=filemtime( get_stylesheet_directory() .'/css/child-style.css'), 'all' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is a similar snippet for JS
// Enqueue Custom Gravity Form JS add_action( 'wp_enqueue_scripts', 'gravityjs_enqueue_script' ); function gravityjs_enqueue_script() { wp_register_script( 'custom-gravity-js', get_template_directory_uri() . '-child/scripts/gravity_form.js', array(), $ver=filemtime( get_stylesheet_directory() .'/scripts/gravity_form.js'), 'all' ); wp_enqueue_script( 'custom-gravity-js' ); }