I have a plugin that I want to add a stylesheet to each "edit category" page because I added additional custom fields into those pages.
Is there a simple way of doing this or do I have to use the URL and add it individually using add_action()
?
The way to enqueue admin styles and scripts in targeted pages is explained here:
Difference between do_action('admin_enqueue_scripts', $hook_suffix) and do_action("admin_print_styles-$hook_suffix") syntax
The Category page is the same as the Tag page, /wp-admin/edit-tags.php
. So, an extra check is needed and in this case using the global variable $current_screen
.
add_action( 'admin_print_styles-edit-tags.php', function(){
global $current_screen;
// Not categories, do nothing
if( 'edit-category' != $current_screen->id )
return;
// Debug
echo "<script>alert('$current_screen->id')</script>";
// wp_enqueue_style() call here
});