Skip to content

Instantly share code, notes, and snippets.

@aliaramli
Last active December 10, 2020 15:18
Show Gist options
  • Save aliaramli/b263e4fb8f3b98901aec8efb243b3f12 to your computer and use it in GitHub Desktop.
Save aliaramli/b263e4fb8f3b98901aec8efb243b3f12 to your computer and use it in GitHub Desktop.
Sample adding Javascript and CSS files to Wordpress
function wp_add_javascripts() {
wp_enqueue_script('utils-js',
get_stylesheet_directory().'/assets/js/utils.js', array('jquery'),'1.1', true);
}
function wp_add_styles() {
wp_enqueue_style('utils-css',
get_stylesheet_directory().'/assets/css/utils.css');
}
//add to the wp_enqueue_scripts hook.
add_action( 'wp_enqueue_scripts', 'wp_add_javascripts' );
add_action( 'wp_enqueue_scripts', 'wp_add_styles' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment