![wordpress enqueue script on specific admin page wordpress enqueue script on specific admin page](https://dethihsg247.com/wp-content/uploads/2020/11/rzigs.jpg)
In the third parameter I’ve specified jQuery as a dependency. The third asset I’ve added is the excellent Owl Carousel. The first parameter is the unique name of the asset, the second is its location. This is not a problem since I defined this dependency in the third parameter. I defined our theme style first, even though it depends on the reset style. The first two things I enqueued were our styles. Note that both scripts and styles are enqueued by attaching a function to the wp_enqueue_scripts hook. This code should be placed in the functions.php file of our theme, child theme, or in a plugin file. The example below shows three scripts and two styles loaded on a website: No matter how you attach your assets, the end result will be a or a tag somewhere in your website’s HTML. It takes all the information from what is needed by the core, by your theme and your plugins, creates a list of scripts and styles needed, and outputs them in the correct location. You can even specify the dependencies of your scripts and styles and WordPress will add them in the correct order. If each plugin linked to these assets separately, chaos would ensue and all your JavaScript could stop working.īy enqueueing scripts you are telling WordPress about the assets you want to add and it will take care of actually linking to them in the header and footer.
![wordpress enqueue script on specific admin page wordpress enqueue script on specific admin page](https://www.thecodehubs.com/wp-content/uploads/2020/03/how-to-enqueue-css-and-js-file-using-wordpress-1-1280x382.png)
Multiple plugins you have may use jQuery and other shared scripts.
WORDPRESS ENQUEUE SCRIPT ON SPECIFIC ADMIN PAGE HOW TO
In this article, I’ll show you how to add scripts and styles to your themes and plugins, whether you are creating something on the front-end or in the backend.Įnqueueing is a CMS-friendly way of adding scripts and styles to WordPress websites. Instead of plopping them into the header or footer file we need to use WordPress’ enqueue functionality. It is important to note however, that the way you add these scripts to WordPress is just as important as the content of these files. Many of us use styles to alter the look of our website, and scripts to enhance functionality.