Created
December 14, 2015 14:32
-
-
Save jfeliweb/88840cd195dedb4f4c98 to your computer and use it in GitHub Desktop.
Enqueue Script for WordPress
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
| /* Proper way to enqueue scripts and styles */ | |
| function mytheme_custom_scripts(){ | |
| // Register and Enqueue a Stylesheet | |
| // get_template_directory_uri will look up parent theme location | |
| wp_register_style( 'name-of-style', get_template_directory_uri() . '/css/custom-style.css'); | |
| wp_enqueue_style( 'name-of-style' ); | |
| // Register and Enqueue a Script | |
| // get_stylesheet_directory_uri will look up child theme location | |
| wp_register_script( 'name-of-script', get_stylesheet_directory_uri() . '/js/custom-script.js', array('jquery')); | |
| wp_enqueue_script( 'name-of-script' ); | |
| } | |
| add_action('wp_enqueue_scripts', 'mytheme_custom_scripts'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment