You can use this in your functions.php :
function add_admin_scripts( $hook ) {
if ( $hook == 'post-new.php' ) {
wp_enqueue_script( 'myscript', get_bloginfo('template_directory').'/js/myscript.js' );
}
}
add_action('admin_enqueue_scripts','add_admin_scripts',10,1);
Related Posts:
- How do I Enqueue styles/scripts on Certain /wp-admin Pages?
- Why are admin scripts not printed
- How to disable 3.3 Tooltips?
- Enque script based on url paramater
- How to use underscore.js in WordPress Admin
- Trying to get custom js files in my admin header
- load-{$page hook} and returned parameter
- Why is WordPress enqueuing admin relevant scripts (e.g., React, ReactDOM, Redux, hooks, TinyMCE etc) when not logged in?
- How to load Dashboard default media files via HTTPS even when Browser URL has HTTP
- Conditions for admin get_current_screen action parent_file edit.php?post_type=page
- admin_print_styles incuding $_SERVER[‘DOCUMENT_ROOT’]
- adding custom stylesheet to wp-admin
- Disable dragging of meta boxes?
- How to remove the core embed blocks in WordPress 5.6?
- How to order by post meta name in wp admin?
- How set defaults on wpLink()
- Remove dashboard, use Pages tab as default
- How to list ALL Pages in the dashboard?
- “leftover” notifications left on ever admin screen?
- Excerpt textarea missing on post editing page in admin panel
- Dashboard links not working
- Resize Admin Featured Image Thumbnail in CPT Edit Screen
- Registering jQuery kills admin functions
- Adding HTML/Text to Top of Subscriber’s Profile Backend Page
- WordPress address URL keeps dropping the www
- Cannot Access Admin Area After Migration
- Having troubles connecting to WordPress login page using Mamp
- ‘wp’ hook supposed to trigger when editing a post?
- How do you force the wordpress dashboard to be 1 coulmn by default?
- How to remove dashboard access (wp-admin) for author but not disable the capabilities?
- always by default show welcome panel in the dashboard
- Migrated wordpress site give “Undefined variable: php” warnings
- Add and Remove Row Actions in an Existing WP_List_Table
- I am unable to login into my wp-admin
- Is it possible to take over a WordPress site if the old administrator is MIA?
- Dashboard Widget CSS
- How can I prevent redirects from mysite/page to mysite/wp path/page?
- How can I prevent a function from loading in the admin screens?
- Add styles to wordpress admin on the Page List
- making users.php search include a specific user meta data field without messing with the SQL query itself
- Move WooCommerce menu entries to top of dashboard
- Redirect an entire WordPress site on a subdomain, except wp-admin
- WordPress Admin Toolbar Disappeared when moved site to subfolder
- Admin sometimes redirects to HTTPS
- WP Core hard coded to use http://www.w3.org/1999/xhtml not HTTPS
- Hide user group filtering links
- 404 Admin Error
- Fix Admin Dashboard Posts tab
- auto generated robots.txt problem
- Change maxlength of link_description in dashbord link section?
- Add a custom field when adding / editing a page / post in admin panel
- View all comments on post one click
- wordpress wp-admin/includes/shema.php file has been modify alone
- Broken Customizer page
- I can’t access my wp admin dashboard
- wp-admin going directly to 404
- Should I move wp-admin to a separated server? How to do it?
- WP-Admin throws 404 after changing wp-config Salts
- How to create a new section on the wordpress admin dashboard?
- What event I can tap into that fires before loading wp-admin page?
- Weird white space in admin area
- How to logout the current user without notices and warnings?
- Updated to wordpress 5.5.1 doesn’t work
- How can I change block editors suggested links to display another url (i.e. from api.mysite to www.mysite)
- How to fix the view of admin all posts
- mixed contents admin panel is Unsecured
- Link with password is not sent to the new user
- How to change labels in the projects page
- Can’t access Network Admin dashboard in wp-admin
- Can I rename the wp-admin folder?
- How do I list subpages in post editor view?
- Remove View details option from plugin listing
- wp-admin won’t load for users behind a Barracuda F600 firewall
- WordPress wp-admin login problem
- Failed to load resource: the server responded with a status of 431 ()
- Database problem
- WordPress Admin Page Redirecting to Subdomain
- Remove Theme menu link from Admin Panel
- Why does my edit screen suddenly have such a buggy interface?
- Disabling WP-Admin Caching in htaccess
- Unable to log in as admin
- Add files to wordpress admin panel footer
- Can I rename the wp-admin folder?
- WordPress Child problem in admin
- SSL doesn’t deliver parts of WordPress Administration Module
- WordPress admin option, I can’t use jquery ajax to access my content from another file
- Why WordPress not logout after I have close my browser?
- How to display product category’s individual product list in shop page?
- Images on admin backend not showing up
- WordPress br in content problem
- How to troubleshoot 404s in WordPress admin
- Launch wordpress site to local computer from live website backed-up
- How do I unset all of the select boxes for pages
- wp-admin won’t “remember me” in Chrome & Firefox
- Override WordPress Core File?
- WordPress Users page missing user count next to different types of users
- Not receiving verification email to update administrator email in wordpress
- contact form 7 form not working in admin panel
- Is there a way to get the WP Admin Header to inject as the first element in the body instead of the last?
- Creating an custom admin page from scratch