WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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.