It’s possible to add css modifications to WordPress admin panel?

I’m making a theme for wordpress and I don’t know how to apply a custom set of css rules that will remain still when wordpress will get updated.
Is there any way that I can apply a css file using functions.php from my theme?
Thank you!

Related posts

Leave a Reply

1 comment

  1. This kind of feature doesn’t belong on functions.php. See: Where to put my code: plugin or functions.php?

    Create your own plugin and enqueue your custom CSS and Javascript files (normally, jQuery is quite useful and some nice effects can be added).

    wp-content/plugins/my-plugin/my-plugin.php

    <?php
    /**
     * Plugin Name: Admin Styles
     * Description: Add custom CSS to Admin area
     * Version:     1.0
     * Author:      brasofilo
     * Author URI:  http://stackoverflow.com/users/1287812/brasofilo
     */
    
    add_action( 'admin_enqueue_scripts', 'b5f_admin_enqueue' );
    
    /**
     * Register and enqueue Scripts and Styles
     */
    function b5f_admin_enqueue()
    {
        wp_register_style(
            'b5f_admin_style', // Style handle
            plugins_url( '/my-plugin.css', __FILE__ ), // Style URL
            null, // Dependencies
            null, // Version
            'all' // Media
        );
        wp_enqueue_style( 'b5f_admin_style' );
    
        wp_register_script(
            'b5f_admin_script', // Script handle
            plugins_url( '/my-plugin.js', __FILE__ ), // Script URL
            array( 'jquery' ), // Dependencies. jQuery is enqueued by default in admin
            null, // Version
            true // In footer
        );
        wp_enqueue_script( 'b5f_admin_script' );
    }
    

    wp-content/plugins/my-plugin/my-plugin.css

    h2 { font-size: 3em !important }
    

    wp-content/plugins/my-plugin/my-plugin.js

    // See: http://api.jquery.com/category/selectors/
    jQuery(document).ready( function($) {
        $("div[id^='icon']").hide(); 
    });
    

    Check all WordPress available scripts: Default_Scripts_Included_and_Registered_by_WordPress.