Wp enqueue
![wp enqueue wp enqueue](https://techmemo.biz/wp-content/uploads/2019/08/wp-localize-script.jpg)
Technically scripts and styles are first registered and then enqueued. Registration for Stylesheet and Wp Enqueue Script '/custom.css') Īdd_action('wp_enqueue_scripts', ' ls_add_myscripts') Wp_enqueue_style( 'style-name', get_template_directory_uri(). Wp_enqueue_script( 'script-name', get_template_directory_uri(). For example screen, print, handheld, etc.Įxample for enqueueing style and scripts:
![wp enqueue wp enqueue](https://maisonbisson.com/post/on-wp_enqueue_scripts-and-admin_enqueue_scripts/0_huafc02eb1e36d329863a692a9cf8a784f_8789_1200x1200_fill_q75_gaussian_smart1.jpg)
dependencies: An array of handles to assets which your script or style depends on.Make sure to use functions like get_template_directory_uri() or plugins_uri(). source: The URL of your script or style.It is best to use only lowercase letters and dashes here, and make sure to use a unique name. handle: This is the name of your script or style.Wp_enqueue_style( $handle, $source, $dependencies, $version, $media ) Wp_enqueue_script( $handle, $source, $dependencies, $version, $in_footer ) You can add this enqueueing or Dequeueing code in your theme’s functions.php file of your active child theme (or theme) or plugin file. You can even specify the dependencies of your scripts and stylesheets and WordPress will add them in the correct order. Using enqueueing functionality, WordPress can be linking this stylesheet and script in the header and footer. What is Wp Enqueueing Script?Įnqueueing is a CMS-friendly way of adding scripts and styles to WordPress websites. Most of the time we all are added it in header and footer but we can also use WP enqueue script functionality to add scripts and stylesheets in WordPress.
#Wp enqueue how to
Also, it is important to how to add these script and stylesheet to WordPress. Using stylesheet and script to make your website beautiful and attractive.