I want to add some styles to the widgets input fields. Therefore I want to include a style.css file only on the wp-admin/widgets.php page.

How can I detect the above page and include file there?

1 Answer 1


You can use the following code. Asuming that the css file style.css is inside the css folder of your theme:

function wpse_126614_enque( $hook ) {
    if ( 'widgets.php' != $hook ) {
    $template_url = get_template_directory_uri();
    wp_enqueue_style( 'admin-style-widget', $template_url . '/css/style.css' );
add_action( 'admin_enqueue_scripts', 'wpse_126614_enque' );

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.