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 the category to the admin column for a custom post type?
- Change page title in admin area
- How to filter by post-format in admin?
- Make fonts.com font work in TinyMCE (iframe referrer issue)
- How to remove the site health dashboard widget?
- Securing wp-admin folder – Purpose? Importance?
- stop redirection on /wp-admin call to /wp-login
- Wp3.5 Media Gallery Edit modal: change captions to title
- Admin account only shows Profile and Dashboard with no activity
- Opening specific posts on WP takes lot of time and freezes the editor
- Is it possible to set a option, and then redirect to another page directly from a admin notice link?
- Edit a WordPress site without the username and password?
- How to load a CSS file into WordPress admin area using Child Theme? [closed]
- Getting “Cannot modify header information – headers already sent” error, but only on backend
- How can I remove the new stats message? [closed]
- Cookie value cannot be read until I’ve logged into the WP admin
- How to inhibit dashboard and profile management access to normal users?
- What corrections does this code need?
- Admin Blank Page with Working Front-End After Updating to WordPress 4.6
- Why can’t I exclude private posts from this query?
- Distinguish profile user and admin user IDs / get ID of user being edited
- Moved wordpress from localhost to live and wp-admin shows white screen
- Auto create post title in admin
- Password reset link becomes invalid immediately [closed]
- Get which template being in use within WordPress-admin
- special characters after saving draft interpreted as �
- WordPress and bbPress Login conflicts?
- Allow administrators to pick post author on custom post type edit screen
- /wp-admin/ works but website doesn’t load
- How can I use a variable to include a linked image?
- Add css code in admin_enqueue_scripts
- Add custom list menu on Posts page in admin panel
- Does it matter if two people are using the same WordPress admin account?
- Add column to pages table
- Use Password Protected Form without the use of wp-login.php
- redirect to a dedicated sign in page
- My email address is displaying an email which does not work. What do i do?
- More than one admin logged in?
- Too many redirects after added SSL redirect on port 80 virtual host
- Register page in admin area
- Removing Dashboard Menu Items Through The Database
- “WordPress installations is currently out of date” problem with difficult situation [closed]
- Custom plugin admin page issues
- Making Comments, a sub_menu in admin menu
- Without using wordpress cms Is it possible to signup from my html page
- Customising Word press Admin – Add Post Page functionality to another similar page
- How to add ‘Insert HTML Table’ button to TinyMCE in admin?
- How can I remove commas when adding tags?
- Displaying Title in Title Tag on Edit page?
- How to add custom CSS and JavaScript file for wp- admin dashboard (backend)
- GoDaddy hosting wp-admin problem
- How can I remove unwanted word on my WP site?
- Add custom fields to a page template, admin side
- How to take the help button and link off the dashboard
- Newly created user role not displaying on users screen
- issue with wordpress [wp-admin] redirects, when using kubernetes ingress hosting two wordpress websites using path
- Toggle between block ‘edit content’ and ‘select’ not properly working in WordPress Admin
- WordPress Admin extremely slow when other admin logged in
- Can’t acces login on new site
- WordPress Admin Panel Left Sidebar No showing on Post create page
- WordPress Migration Post Problems
- After changing Site http to https, can’t access wp login page with a digitalocean hosting
- Can’t access WP-Admin via HTTPS
- wp-admin and wp-login.php not Accessible after Cloudflare
- adding existing menu page on new customer user role
- stop customize.php redirect to login page if admin is not logged in
- Random authentication failures on a load balanced WP setup
- Can I get programmatic access to wp-admin?
- Strange URLs admin area bug
- remove_query_arg on options.php
- wp.svgPainter cannot init error, causing issues with admin panel
- mysql_escape_string PROBLEM
- Cannot access my wordpress website
- Organising and display thousands of photos in media library
- Custom comment action
- Problem with admin columns
- get_current_screen – ‘Trying to get property of non-object’ error
- Added fields in quick edit screen need to update at the moment
- Block tools menu in wp-admin?
- is_admin() triggers error
- Modify admin panel tab position
- not able to add thumbnail custom field in dropdown
- No wp-admin, wp-config, or .htaccess folder/file
- Taking over a WordPress site
- wordpress admin is broken [closed]
- LinkControl not showing suggestions when used on admin page
- Redirecting the user to the admin table area after publishing a post, getting an invalid response error?
- How can you change the admin dashboard URL without symlinking?
- WordPress Localhost migration issue