Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I tried the following:

<?php

function my_wp_admin_css() {
  echo '<link rel="stylesheet" href="/wp-content/plugins/custom-admin-style/wp-admin.css" type="text/css" />';
}

add_action('wp_admin_css','my_wp_admin_css');

but nothing is being displayed in the Wordpress admin.

What I'm doing wrong?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You need to use wp_enqueue_style and hook it into admin_print_styles

add_action( 'admin_print_styles' , 'my_wp_admin_css' );

function my_wp_admin_css() {

      wp_enqueue_style('my_admin_style' , WP_PLUGIN_URL . '/myPlugin/stylesheet.css' );
}

If you just want the stylesheet on your plugins page you can use:

$mypage = add_management_page( 'myplugin', 'myplugin', 9, __FILE__, 'myplugin_admin_page' );
add_action( "admin_print_styles-$mypage", 'myplugin_admin_head' );
 
function myplugin_admin_head() {
    // what your plugin needs in its <head>
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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