wp_enqueue_scripts
is only fired on the front end, and not on admin screens. For loading scripts admin side, you’ll want the hook admin_enqueue_scripts
.
Passed as an optional argument is the page hook. (Examples include edit.php
, for the admin edit page (which lists pages/posts/ cpt posts), post.php
when editing a post/ custom post type and post-new.php
when creating a new one).
$screen = get_current_screen();
is also available to you, so you can restrict by post type. E.g.:
add_action( 'admin_enqueue_scripts', 'rw_enqueue_scripts' ,10,1);
function rw_enqueue_scripts($hook){
$screen = get_current_screen();
// Check screen hook and current post type
if ( 'post.php' == $hook && 'product' == $screen->post_type ){
//Load scripts
}
}
Related Posts:
- Seems that admin_post_{action} does not executing
- What are the standard admin CSS id/class tags?
- Modal window from within WordPress admin
- How to Change the Default Home Page for the WordPress Dashboard?
- How To Remove WordPress Version From The Admin Footer
- Set Default Admin Colour For All Users
- Securing Admin Accounts – Username Discovery
- Can an admin check passwords of registered users?
- How-to make the admin area mobile friendly [closed]
- How to obtain the user ID of the current profile being edited in WP-Admin?
- 3.3: How do you hide the new dashboard welcome panel?
- Are there any action like ‘init_frontend’
- Is there a hook to put stylesheet and/or JS inside iframes (thickbox or tinyMCE) in admin area
- A similar hook as wp_head for the admin area
- How to remove items from +New admin menu?
- Appearance->Editor not visible
- Possible to create placeholder images in WordPress editor that are clickable (should bring up uploader)?
- Admin pages have no content
- Blocking Administrative Access to Authors and Subcribers?
- How to find out if an wp-admin action edited a file?
- How to display only logged in user’s post comments in comments area
- How to Remove the “Restore” Link in Quick Edit?
- WordPress 3.8 get current admin color scheme
- How to Use Resposive Tables in WordPress ADMIN Pages?
- Use latest jQuery in WordPress (admin interface)
- How can I access profile Admin Colour Scheme
- I keep getting logged out in Firefox
- Add tabbed menu to admin page
- remove_action with profile_personal_options
- Getting the different post statuses + count like in edit.php, in a custom submenu page
- how to redirect to url.com/wp-admin if url.com/admin is typed in?
- How To Create User Specific Admin User Pages?
- Adding markup to column text in “Edit Pages” admin page
- Change the Default Pages Menu View in wp-admin
- Disable HTML (Text) Tab in Post Editor
- Conditionally load CSS/JS/PHP in wp-admin if using a mobile device
- How to disable automatic excerpt generation *in admin*?
- Limit Words in Category / Term Description – Admin Panel
- Change top level menu item to point to custom submenu item
- Associating custom submenu item with post type of top level menu item
- Manage users custom column add class “num”
- Adding text in more than one language (at the same time)
- wp-admin post.php JavaScript Links Not Working
- Custom Thickbox Broken on Dashboard Page?
- Super slow admin panel
- Admin Taxonomy Terms – Orderby Term Field
- How do I add an admin notice within javascript in the admin interface for posts?
- Fatal error: Exception thrown without a stack frame in Unknown on line 0
- Hide Pages on Edit Pages based on Capability (edit_others_pages)?
- Where should I hook into admin?
- Problems with WP_List_Table and hooks
- Unable to Access WP Admin or Login buttons after Migration
- Add ‘Last Modified’ and Attachments (Yes/No) to WordPress Users Column
- Editors change a permalink on an unpublished post, but only admins change a permalink on a post that has ever been published?
- How Can I Found Admin Directory
- WordPress post feature image not uploading
- Combine and Minify wp-admin files, also re-write URI’s for CDN
- 500 internal server error on wp-admin only
- Grabbing how Many Posts by Month for a Dashboard Widget
- Redirect from the dashboard to edit.php if wp_is_mobile() is true
- Why can’t a custom postype be registered with “admin_init” hook?
- Remove Permalink From Admin Edit Post
- Show excerpt if no title in admin view
- Add sub menu page in your plugin
- Add Custom Script in Other Plugin’s Options page
- When submitting the form site.com/blog/wp-admin it goes to site.com/wp-admin
- Can I host WP-admin locally for a remote blog?
- Is there alternative to WP_List_Table?
- WordPress Brute Force Prevention
- Admin login not working
- Filter WooCommerce Orders
- Adding and removing columns from the admin pages panel
- How to make sure your admin doesn’t hi-jack you site?
- Send admin to a different login than users?
- How to change the descriptive text on the menus admin page?
- Dynamic WordPress Admin Panel
- Wp-Admin FTPS Connection Error unlike Filezilla
- Remove iPhone detection on login page
- ‘Conflict’ with action deleted_post and is_admin()
- How to update my website with WordPress?
- wordpress login loop after install
- Unable to render Admin Notices
- WordPress login not working
- Admin blank but Admin menu showing
- Capability to read/edit page in wp-admin only for administrators
- Problems in migration of WordPress site from local server to the online server
- WYSIWYG editor not in a post editor?
- htaccess and htpasswd
- plugin to upload to youtube via wordpress [closed]
- You do not have permission to access this document on form submit
- Add custom column to Users admin panel
- Get current active wp color scheme
- How to fix admin stylesheet muck-up? [closed]
- Why adding Categories does not auto refresh in Backend while using my custom theme?
- Set admin body to ltr on a rtl installation
- Can I mass change all admin emails for a multisite instance?
- Remove metabox from WordPress menu editor page?
- Can’t access wp-admin, redirects to http://%24domain/wp-admin/
- remove menus for a specific role?
- Hiding the media-new.php File URL option via jQuery