0

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()?

1 Answer 1

1

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
});    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.