WordPress add JavaScript to admin
Here is how to add custom JavaScript to WordPress admin area (dashboard):
Just copy code below and paste it to your themes functions.php file.
Dont forget to change "your-theme/assets/js/CustomJS.js"
with path to your JS file.
// Add Custom JS to WordPress Admin Area Footer function custom_admin_js() { echo '<script type="text/javascript" src="' . esc_url( home_url( '/' ) ) . 'wp-content/themes/your-theme/assets/js/CustomJS.js"></script>'; } add_action('admin_footer', 'custom_admin_js'); |
// Add Custom JS to WordPress Admin Area Header function custom_admin_js() { echo '<script type="text/javascript" src="' . esc_url( home_url( '/' ) ) . 'wp-content/themes/your-theme/assets/js/CustomJS.js"></script>'; } add_action('admin_head', 'custom_admin_js'); |
Leave a Reply