5

Is there a way to override the styles in the admin in my theme?

I don't want to touch the admin style sheet if I don't have to.

I just want to make a column bigger in my admin, but also, to do it in a way that doesn't get overridden in a future wordpress update.

10

Take a look here at the CODEX for an example on how to do this very thing.

Example: Load CSS File on All Admin Pages

function load_custom_wp_admin_style(){
    wp_register_style( 'custom_wp_admin_css', get_bloginfo('stylesheet_directory') . '/admin-style.css', false, '1.0.0' );
    wp_enqueue_style( 'custom_wp_admin_css' );
}
add_action('admin_enqueue_scripts', 'load_custom_wp_admin_style');

Example: Target a Specific Admin Page

function my_enqueue($hook) {
    if( 'edit.php' != $hook )
    return;
    wp_enqueue_script( 'my_custom_script', plugins_url('/myscript.js', __FILE__) );
}
add_action( 'admin_enqueue_scripts', 'my_enqueue' );
  • Does the css I create "add" to the current admin style? I only need to override 1 style so I don't want to have to skin the entire admin side... – redconservatory Mar 7 '12 at 15:38
  • correct, it adds to the already existing styles – The Z Man Mar 7 '12 at 15:47
  • this worked fine. I'll just add that more modern way to give path to stylesheet is get_stylesheet_directory_uri() instead of get_bloginfo('stylesheet_directory') – yitwail Feb 23 '13 at 18:02
2

You can use the admin_enqueue_scripts hook in combination with wp_enqueue_style in a manner similar to this:

// you may want to wrap add_action() in a conditional to prevent enqueue on every page
add_action( 'admin_enqueue_scripts', 'wpse44753_admin_enqueue' );

function wpse44753_admin_enqueue() {
    wp_enqueue_script(
        'wpse44753_style',
        'script/location/here.css', // you probably want to use plugins_url() for this
    );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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