Last active
February 19, 2018 20:45
-
-
Save danielpataki/367fa92182f3fbaa10c8 to your computer and use it in GitHub Desktop.
WordPress Enqueues
This file contains 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
function my_assets() { | |
wp_register_script( 'owl-carousel', get_stylesheet_directory_uri() . '/owl.carousel.js', array( 'jquery' ) ); | |
wp_enqueue_script( 'owl-carousel' ); | |
} | |
add_action( 'wp_enqueue_scripts', 'my_assets' ); |
This file contains 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
function my_assets() { | |
wp_enqueue_style( 'theme-style', get_stylesheet_uri(), array( 'reset' ) ); | |
wp_enqueue_style( 'reset', get_stylesheet_directory_uri() . '/reset.css' ) ); | |
wp_enqueue_script( 'owl-carousel', get_stylesheet_directory_uri() . '/owl.carousel.js', array( 'jquery' ) ); | |
wp_enqueue_script( 'theme-scripts', get_stylesheet_directory_uri() . '/website-scripts.js', array( 'owl-carousel', 'jquery' ), '1.0', true ); | |
} | |
add_action( 'wp_enqueue_scripts', 'my_assets' ); |
This file contains 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
wp_enqueue_script( $handle, $source, $dependencies, $version, $in_footer ); | |
wp_enqueue_style( $handle, $source, $dependencies, $version, $media ); |
This file contains 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
function my_assets() { | |
wp_deregister_script( 'jquery' ); | |
wp_register_script( 'jquery', get_template_directory_uri() . '/jquery-latest.js' ); | |
} | |
add_action( 'wp_enqueue_scripts', 'my_assets' ); |
This file contains 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
<!DOCTYPE html> | |
<head> | |
<script type='text/javascript' src='jquery.js'> | |
<script type='text/javascript' src='owl.carousel.js'></script> | |
<link rel='stylesheet' type='text/css' href='reset.css'> | |
<link rel='stylesheet' type='text/css' href='styles.css'> | |
</head> | |
<body> | |
Website content here | |
<script type='text/javascript' src='website-scripts.js'></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Daniel,
It doesn't seem like Github has a way to make pull requests on Gists, so I wanted to ask if you'd consider merging the edit from my fork.
Found this while working through what the 🔥 enqueing does in WP, via your great article for WPMU DEV. Thanks for the super explanations and clearly illustrative code!!