do_action( 'admin_enqueue_scripts', string $hook_suffix )
Enqueue scripts for all admin pages.
Description Description
Parameters Parameters
- $hook_suffix
-
(string) The current admin page.
Source Source
Changelog Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Selectively enqueue a script in the admin
The admin_enqueue_scripts action hook can also be used to target a specific admin page. In this example we are loading a javascript file in the head section of edit.php.
Figure out your $hook name
If you are unsure what the $hook name of the current admin page of which you want to conditionally load your script is, add this to your page:
Enqueue a custom stylesheet in the admin
Sometimes you want to load a set of CSS and/or Javascript documents to all admin pages. You can do this from within your plugin or from your themes function file:
Another way to load scripts or css in specific admin page by using this function
In this example, we are loading a javascript and a css file in the head section of nav-menus.php page.
Expand full source codeCollapse full source code
Load css and js only on a particular sub-menu page