Ask any question about WordPress here... and get an instant response.
How can I enqueue custom scripts in the WordPress admin area?
Asked on Oct 29, 2025
Answer
To enqueue custom scripts in the WordPress admin area, you can use the `admin_enqueue_scripts` action hook. This allows you to add JavaScript files specifically for the WordPress dashboard.
<!-- BEGIN COPY / PASTE -->
function my_custom_admin_scripts() {
wp_enqueue_script('my-custom-script', plugin_dir_url(__FILE__) . 'js/custom-script.js', array('jquery'), '1.0', true);
}
add_action('admin_enqueue_scripts', 'my_custom_admin_scripts');
<!-- END COPY / PASTE -->Additional Comment:
- Ensure your script path is correct and accessible.
- Use dependencies like 'jquery' if your script requires them.
- Set the last parameter to true to load the script in the footer.
- Always test your scripts in a staging environment before deploying to live.
Recommended Links:
