Ok, I figured it out: If it’s a submenu page, the $hook
looks like this: appearance_page_page-name
instead of going by URL. So the complete code would be this:
function my_function($hook) {
if ( 'appearance_page_page-name' != $hook ) {
return;
}
wp_enqueue_style( 'custom-style', get_template_directory_uri() . 'custom-page/style.css' );
}
add_action( 'admin_enqueue_scripts', 'my_function' );
Related Posts:
- WordPress admin stylesheet
- Adding scripts to admin page in my theme
- Why are my styles being applied to the admin area?
- How to enable enqueue_script to work with a logged in user?
- How can I load an inline script after the enqueued scripts in admin?
- admin_enqueue_scripts not working
- jQuery UI AutoComplete & wp_enqueue_script
- How to enqueue admin content outside admincp
- Fixed layout for admin section
- admin_enqueue_scripts not rending JS file correctly
- Include script files for admin submenu page
- Enqueue script throws error in console
- How do I dequeue a parent theme’s CSS file?
- Check if a script/style was enqueued/registered
- Where in WP can I check history or log of updates of plugins etc?
- How does admin-ajax.php work?
- How to load Widget javascript + css files only if used?
- Is it possible to create a WordPress tour? V3.3.1
- Securing Admin Accounts – Username Discovery
- Can an admin check passwords of registered users?
- Prevent author from changing their posts if admin has modified
- The difference between calling wp_enqueue_scripts to load scripts and styles in custom theme
- Notice that the wp_enqueue_style is not being called correctly!
- Set Featured Image programmatically (in admin) with JavaScript?
- Can I set a default dashboard layout for all users?
- Hyphens vs. periods in the script slug in wp_register_script?
- Taxonomy/category hierarchy lost when editing posts [closed]
- Trying to load different syles for 404.php page
- Making the thumbnails in the backend Media section bigger
- How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
- Customize the upload screen
- How to combine multiple CSS files and concatenate JavaScripts if WordPress recommends enqueuing them?
- How to print the output of the get_num_queries function from frontend to backend?
- Javascript not working in admin
- Downloading entire site locally with httrack
- add_submenu_page set for multiple roles [duplicate]
- Adminstering Large Number of WordPress Sites
- How To Create User Specific Admin User Pages?
- Adding markup to column text in “Edit Pages” admin page
- Disable HTML (Text) Tab in Post Editor
- Admin: global $post empty
- Is my child theme working properly
- Change home-url in dashboard
- Why are files enqueued with wp_enqueue_style and wp_enqueue_script 404 Not Found?
- Admin doesn’t have sufficient permissions to plugin’s page
- wp_enqueue_script Doesn’t Work?
- How to restrict the editors from viewing/editing pages created by admin?
- Admin multiple column sorting
- How do I add a contact form?
- Unable to login, old site with previous developer gone
- How to default display name to first name and last and disable the profile field
- How can I show the contents of only a few users
- How to enqueue JavaScript file that depends on CSS stylesheet
- Editors change a permalink on an unpublished post, but only admins change a permalink on a post that has ever been published?
- Locked out of admin and some pictures don’t show after failed SSL installation
- How-to turn off mobile admin mode?
- How can I make the user names of commentors clickable links to the user’s profile from the admin comment screen?
- Grabbing the first image attached to a post and use it with the admin columns
- Keep Logged in Users out of Admin Panel
- Add Custom Script in Other Plugin’s Options page
- Is there a wp-config.php option or constant that I can set to allow me to download nightly / beta builds?
- I can’t access the login panel on my offline website
- Admin login not working
- How to enqueue scripts in right way in a plugin?
- Adding and removing columns from the admin pages panel
- paginate_links on custom query in admin – ‘sufficient permissions’ error
- Live reload preview just reloads forever
- Hide admin notice when user profile updated
- WordPress Screen options does not show any fields
- Locked out of WordPress website from wrong amount of login attempts
- current_user_can(‘administrator’) not working in custom login
- Deregister scripts from plugin
- How to change the descriptive text on the menus admin page?
- Getting rid of menu items on a custom taxonomy
- WordPress Plugin Admin Tab
- Parsing post->ID in included plugin file
- Gutenberg UI has changed
- Call require_once form admin page with checkbox
- How To Remove Import/Export Option From Tools?
- Bootstrap Integtration
- Highlight active Admin Menu when added though add_menu_page
- How to enqueue a script on a specific URL that contains multiple parts
- Error “Sorry, you are not allowed to access this page”
- Create WordPress Menu Item Without Linking to a Custom Page
- Bootstrap navbar responsiveness on WordPress theme menu not working
- Search Only Works when Logged into Admin
- Different role for free and pro users in wordpress without using bbpress
- WordPress login not working
- How to sort post_meta in edit.php?
- Scripts are not called until I login from wordpress backend
- WP Logs me out after updating anything on dashboard
- Adding additional text fields and image upload to a Page?
- Calculate and save an average in a meta
- How can I print out a single stylesheet or javascript link?
- How to fix: Clicking ‘Quick Edit’ link in Admin (edit.php) makes posts disappear?
- WordPress admin panel is blank
- Use the wordpress admin table
- 2FA for admin login only, is it doable?
- Add a user to edit the layout of a site
- Display notice in block editor after wp_insert_post_data hook