Ahh ok I figured it out while researching. I needed to add the $hook parameter and pass it to my function like so:
function my_admin_enqueue_scripts($hook) {
global $current_screen;
if ( 'post.php' != $hook )
return;
wp_register_script('my-scripts', get_template_directory_uri() . '/js/custom/my-scripts.js' );
wp_enqueue_script('my-scripts');
wp_localize_script('my-scripts', 'wp_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
}
This gave me the results I was looking for. Thank you!
Related Posts:
- Enque script based on url paramater
- Why is WordPress enqueuing admin relevant scripts (e.g., React, ReactDOM, Redux, hooks, TinyMCE etc) when not logged in?
- How do I Enqueue styles/scripts on Certain /wp-admin Pages?
- wp_list_tables bulk actions
- Why are admin scripts not printed
- How to disable 3.3 Tooltips?
- Restrict access to admin but allow admin_post hook
- enqueuing React script and hooking its target div fails to load script
- Looking for a hook to add attachment information to the media library tab
- Add “Page Revised” column to Admin
- Stop loading “collaborators” users on add new post or page?
- Execute script only on certain admin pages
- Stopping user deletion from running on error
- When to use add_action when registering/enqueuing scripts
- ‘wp’ hook supposed to trigger when editing a post?
- How to use underscore.js in WordPress Admin
- Add and Remove Row Actions in an Existing WP_List_Table
- load-{$page hook} and returned parameter
- How can I prevent a function from loading in the admin screens?
- How to check if it’s edit.php & post_type is set?
- How do I add something to the “Edit Tag” page in wp-admin?
- How to load Dashboard default media files via HTTPS even when Browser URL has HTTP
- Remove menu item dashboard for a unique user
- Conditions for admin get_current_screen action parent_file edit.php?post_type=page
- True parameter but jquery register in header and not in the footer with wp_register_script
- Custom comment action
- admin_print_styles incuding $_SERVER[‘DOCUMENT_ROOT’]
- JavaScript file successfully registered but does not render correctly
- Action for opening edit page in admin?
- When should I use wp_register_script() with wp_enqueue_script() vs just wp_enqueue_script()?
- Adding custom columns to custom post types
- Adding Fields to the Category, Tag and Custom Taxonomy Edit Screen in the WordPress Admin?
- Admin ajax request return 0 with die()
- How to remove comments option from wp-admin bar and modify profile icon
- Add header and footer to WP backend
- Edit specific nodes in WP_Admin_Bar
- Filter Custom Post Type in Admin
- Enqueue script only when shortcode is used, with WP Plugin Boilerplate
- How can I make WordPress work with a Symfony app?
- Using the loop inside admin
- Display sortable User meta column in admin panel user’s page
- Can’t access admin dashboard with wp-admin without /index.php after it
- How to change “wp-admin” to something else without search-replacing the core?
- Hooking into register_admin_color_schemes
- How can I add an extra admin column showing the word-count of a page or post?
- Which actions can update/change .php files?
- Blank page for edit.php
- Upload media file problem
- Why should I password protect WP-Admin?
- How to change how long items are kept in the trash?
- Can’t get JS code to work with shortcode
- Custom role based users are not able to access wp-admin
- How can I add ‘view mode’ to screen options for pages and cpts?
- Cannot log into WordPress Dashboard after removing/adding .htaccess
- My wp-admin stops working suddenly
- How to debug “You do not have sufficient permissions to access this page”? [closed]
- Why isn’t jQuery 2.1 loading in the header?
- Same Conditionals Not Working on Two Different Hooks
- How to check if upload window came from the featured image link?
- Admin search not working for any type of post
- admin_post action not usable if admin access denied to user
- Can’t log into wp-admin after migration from localhost to server
- Not sure if enqueuing js scripts properly
- Adding Custom Capabilites
- Can I add my own profile.php?
- Wp-admin is giving me an error “Sorry, you are not allowed to access this page.”. I do have access to the wp-admin besides the dashboard itself
- Remove bulk option row
- Admin menu in front-end
- Require Login Redirect to Login Page
- post-new.php?post_type=product is not loading properly
- wp-admin redirects to 404
- Generate PDF using tcpdf from WordPress admin side custom page [closed]
- Renaming wp-admin without hard-coding it. Is it really possible?
- If a Script has been enqueued but not registered can I still removed it?
- add_submenu_page() issue
- Unable to properly login
- Dashboard : remove Safari navigator message
- jQuery plugin not loading
- Create new user from phpMyAdmin
- how to stop wordpress admin menu from scrolling with page
- How to have WP admin in English while public website is in another language?
- Trying to create a page as a menu item in the admin while keeping the admen panel visible
- Moving Javascript from footer to header
- Remove “Filter” Button on All Posts in wp-admin
- only last option from theme options is being saved to the DB
- Give wp-admin access for shop managers
- Cannot log in to WordPress admin or change password
- Cached php? Updates are rendering only if logged as admin
- Js errors in wp-admin
- Avoid executing a function (redirect) if I’m in the admin area
- Symlinking WordPress WP-ADMIN and WP-INCLUDES
- sharing wp-include – wp-admin on same installation
- Admin Scripts enqueue codes seems ok but not working
- admin-post.php results on white screen after form submission
- CSS not showing up in my website Only HTML Displaying
- How to protect wp-admin from third party access?
- Unable to access my plugins [closed]
- Only Admin receives email
- is exposed wp-admin site a serious security vulnerability
- fails upload images in posts + wp-admin/upload.php 403 error