{"id":1984,"date":"2020-10-10T10:42:12","date_gmt":"2020-10-10T02:42:12","guid":{"rendered":"https:\/\/www.intelliwolf.com\/?p=1984"},"modified":"2020-10-10T10:42:15","modified_gmt":"2020-10-10T02:42:15","slug":"add-custom-css-wordpress-admin-area","status":"publish","type":"post","link":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/","title":{"rendered":"How To Add Custom CSS To WordPress Admin Area"},"content":{"rendered":"\n

Sometimes it's nice to add a bit of custom styling to the WordPress admin area to make things stand out a bit better.<\/p>\n\n\n\n

Today I needed to resize a meta box in the sidebar of the Gutenberg editor.<\/p>\n\n\n\n

We had lots of options for membership levels, but it was annoying to have to scroll through to see them to choose them.<\/p>\n\n\n\n

\"\"<\/figure><\/div>\n\n\n\n

How to add custom CSS to the WordPress admin area:<\/strong><\/p>\n\n\n\n

  1. Add a stylesheet<\/a> with your styling to your child theme called admin-style.css<\/em>.<\/li>
  2. Create a function<\/a> in functions.php<\/em> to add wp_enqueue_style<\/em> for admin-style.css<\/em>.<\/li>
  3. Use add_action<\/em> to connect the function<\/a> to the admin_enqueue_scripts<\/em> hook.<\/li><\/ol>\n\n\n\n

    If you just want the code without the explanation, it is:<\/p>\n\n\n\n

    add_action( 'admin_enqueue_scripts', 'my_admin_style');\n\nfunction my_admin_style() {\n  wp_enqueue_style( 'admin-style', get_stylesheet_directory_uri() . '\/admin-style.css' );\n}<\/code><\/pre>\n\n\n\n

    Let's go through the steps in detail.<\/p>\n\n\n\n

    Add a stylesheet with your styling<\/h2>\n\n\n\n

    For this method, we're going to be adding and editing files in the theme. You should always use a child theme for this. Please see my tutorial on how to create a child theme<\/a> if you don't have one yet. It's pretty simple and will only take a few minutes.<\/p>\n\n\n\n

    We will be adding an external stylesheet to the admin area.<\/p>\n\n\n\n

    Start by adding a file to your child theme.<\/p>\n\n\n\n

    If you're not sure how to add files to your theme, I have tutorials on how to edit files in cPanel<\/a> and how to edit files through FTP<\/a> that might be useful.<\/p>\n\n\n\n

    You can't add files using the inbuilt WordPress Theme Editor, so you'll have to add them using one of those methods.<\/p>\n\n\n\n

    You can create or add the admin stylesheet as a blank file and then edit it in the WordPress Theme Editor if you prefer. The advantage of doing it that way is the Theme Editor won't let you save a file that will break your site.<\/p>\n\n\n\n

    I've called the file \"admin-style.css\" for ease of use. You can call it whatever you like and put it in a subfolder if it makes sense to your theme. Just remember what you called it and where you put it for the next step.<\/p>\n\n\n\n

    In the file, I've added this CSS:<\/p>\n\n\n\n

    \/* Admin Styles *\/\n#hforce_content_access_restriction {\n  height: 250px;\n}<\/code><\/pre>\n\n\n\n

    The default style that sets the height of the \"select multiple\" metaboxes in the Gutenberg editor is .wp-core-ui select[multiple]<\/em> but I had an ID that I could hook into just for this one.<\/p>\n\n\n\n

    You don't need to add a special set of tags to this stylesheet like you do with style.css<\/em>. You can just get straight into the CSS like you might write in the Advanced CSS module in the Theme Customizer.<\/p>\n\n\n\n

    Create a function to enqueue the stylesheet<\/h2>\n\n\n\n

    In functions.php<\/em> of you child theme, we're going to enqueue the admin stylesheet in a similar way to how you enqueued style.css<\/em> for the child theme.<\/p>\n\n\n\n

    Don't use the same function to do this, because we only want the admin styles outputting to the admin area, not all the frontend styles that you have in style.css<\/em>.<\/p>\n\n\n\n

    Because we're doing this in a child theme, the code is:<\/p>\n\n\n\n

    function my_admin_style() {\n  wp_enqueue_style( 'admin-style', get_stylesheet_directory_uri() . '\/admin-style.css' );\n}<\/code><\/pre>\n\n\n\n

    If you were developing your own theme, the code you'd use would be:<\/p>\n\n\n\n

    function my_admin_style() {\n  wp_enqueue_style( 'admin-style', get_template_directory_uri() . '\/admin-style.css' );\n}<\/code><\/pre>\n\n\n\n

    Make sure you replace '\/admin-style.css'<\/em> with the name and location of your stylesheet, if you did something different.<\/p>\n\n\n\n

    Connect the function to the hook<\/h2>\n\n\n\n

    The final step is to add an action to trigger the function.<\/p>\n\n\n\n

    Add this code to your functions.php<\/em> file:<\/p>\n\n\n\n

    add_action( 'admin_enqueue_scripts', 'my_admin_style');<\/code><\/pre>\n\n\n\n

    Save that and you should see your admin style reflected in the admin area.<\/p>\n\n\n\n

    Now the metabox on the Gutenberg editor is a more useable height.<\/p>\n\n\n\n

    \"\"<\/figure><\/div>\n\n\n\n

    <\/p>\n","protected":false},"excerpt":{"rendered":"

    Sometimes it’s nice to add a bit of custom styling to the WordPress admin area to make things stand out a bit better. Today I needed to resize a meta box in the sidebar of the Gutenberg editor. We had lots of options for membership levels, but it was annoying to have to scroll through<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"yoast_head":"\nHow To Add Custom CSS To WordPress Admin Area<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Add Custom CSS To WordPress Admin Area\" \/>\n<meta property=\"og:description\" content=\"Sometimes it's nice to add a bit of custom styling to the WordPress admin area to make things stand out a bit better. Today I needed to resize a meta box in the sidebar of the Gutenberg editor. We had lots of options for membership levels, but it was annoying to have to scroll through\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/\" \/>\n<meta property=\"og:site_name\" content=\"Intelliwolf\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-10T02:42:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-10-10T02:42:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2020\/10\/2020-10-10-add-custom-css-admin-01.png\" \/>\n<meta name=\"author\" content=\"Mike Haydon\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mike Haydon\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/\"},\"author\":{\"name\":\"Mike Haydon\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343\"},\"headline\":\"How To Add Custom CSS To WordPress Admin Area\",\"datePublished\":\"2020-10-10T02:42:12+00:00\",\"dateModified\":\"2020-10-10T02:42:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/\"},\"wordCount\":601,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2020\/10\/2020-10-10-add-custom-css-admin-01.png\",\"articleSection\":[\"Theme Customization\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/\",\"url\":\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/\",\"name\":\"How To Add Custom CSS To WordPress Admin Area\",\"isPartOf\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2020\/10\/2020-10-10-add-custom-css-admin-01.png\",\"datePublished\":\"2020-10-10T02:42:12+00:00\",\"dateModified\":\"2020-10-10T02:42:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#primaryimage\",\"url\":\"https:\/\/www.intelliwolf.com\/wp-content\/uploads\/2020\/10\/2020-10-10-add-custom-css-admin-01.png\",\"contentUrl\":\"https:\/\/www.intelliwolf.com\/wp-content\/uploads\/2020\/10\/2020-10-10-add-custom-css-admin-01.png\",\"width\":330,\"height\":298},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.intelliwolf.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Theme Customization\",\"item\":\"https:\/\/www.intelliwolf.com\/category\/theme-customization\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How To Add Custom CSS To WordPress Admin Area\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.intelliwolf.com\/#website\",\"url\":\"https:\/\/www.intelliwolf.com\/\",\"name\":\"Intelliwolf\",\"description\":\"WordPress, Web Design & Coding Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.intelliwolf.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\",\"name\":\"Intelliwolf\",\"url\":\"https:\/\/www.intelliwolf.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.intelliwolf.com\/wp-content\/uploads\/intelliwolf-logo-300t.png\",\"contentUrl\":\"https:\/\/www.intelliwolf.com\/wp-content\/uploads\/intelliwolf-logo-300t.png\",\"width\":300,\"height\":100,\"caption\":\"Intelliwolf\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343\",\"name\":\"Mike Haydon\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g\",\"caption\":\"Mike Haydon\"},\"sameAs\":[\"https:\/\/intelliwolf.com\/about-mike-haydon\/\"]}]}<\/script>\n","yoast_head_json":{"title":"How To Add Custom CSS To WordPress Admin Area","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/","og_locale":"en_US","og_type":"article","og_title":"How To Add Custom CSS To WordPress Admin Area","og_description":"Sometimes it's nice to add a bit of custom styling to the WordPress admin area to make things stand out a bit better. Today I needed to resize a meta box in the sidebar of the Gutenberg editor. We had lots of options for membership levels, but it was annoying to have to scroll through","og_url":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/","og_site_name":"Intelliwolf","article_published_time":"2020-10-10T02:42:12+00:00","article_modified_time":"2020-10-10T02:42:15+00:00","og_image":[{"url":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2020\/10\/2020-10-10-add-custom-css-admin-01.png"}],"author":"Mike Haydon","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mike Haydon","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#article","isPartOf":{"@id":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/"},"author":{"name":"Mike Haydon","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343"},"headline":"How To Add Custom CSS To WordPress Admin Area","datePublished":"2020-10-10T02:42:12+00:00","dateModified":"2020-10-10T02:42:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/"},"wordCount":601,"commentCount":3,"publisher":{"@id":"https:\/\/www.intelliwolf.com\/#organization"},"image":{"@id":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#primaryimage"},"thumbnailUrl":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2020\/10\/2020-10-10-add-custom-css-admin-01.png","articleSection":["Theme Customization"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/","url":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/","name":"How To Add Custom CSS To WordPress Admin Area","isPartOf":{"@id":"https:\/\/www.intelliwolf.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#primaryimage"},"image":{"@id":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#primaryimage"},"thumbnailUrl":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2020\/10\/2020-10-10-add-custom-css-admin-01.png","datePublished":"2020-10-10T02:42:12+00:00","dateModified":"2020-10-10T02:42:15+00:00","breadcrumb":{"@id":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#primaryimage","url":"https:\/\/www.intelliwolf.com\/wp-content\/uploads\/2020\/10\/2020-10-10-add-custom-css-admin-01.png","contentUrl":"https:\/\/www.intelliwolf.com\/wp-content\/uploads\/2020\/10\/2020-10-10-add-custom-css-admin-01.png","width":330,"height":298},{"@type":"BreadcrumbList","@id":"https:\/\/www.intelliwolf.com\/add-custom-css-wordpress-admin-area\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.intelliwolf.com\/"},{"@type":"ListItem","position":2,"name":"Theme Customization","item":"https:\/\/www.intelliwolf.com\/category\/theme-customization\/"},{"@type":"ListItem","position":3,"name":"How To Add Custom CSS To WordPress Admin Area"}]},{"@type":"WebSite","@id":"https:\/\/www.intelliwolf.com\/#website","url":"https:\/\/www.intelliwolf.com\/","name":"Intelliwolf","description":"WordPress, Web Design & Coding Tutorials","publisher":{"@id":"https:\/\/www.intelliwolf.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.intelliwolf.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.intelliwolf.com\/#organization","name":"Intelliwolf","url":"https:\/\/www.intelliwolf.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.intelliwolf.com\/wp-content\/uploads\/intelliwolf-logo-300t.png","contentUrl":"https:\/\/www.intelliwolf.com\/wp-content\/uploads\/intelliwolf-logo-300t.png","width":300,"height":100,"caption":"Intelliwolf"},"image":{"@id":"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343","name":"Mike Haydon","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g","caption":"Mike Haydon"},"sameAs":["https:\/\/intelliwolf.com\/about-mike-haydon\/"]}]}},"_links":{"self":[{"href":"https:\/\/www.intelliwolf.com\/wp-json\/wp\/v2\/posts\/1984"}],"collection":[{"href":"https:\/\/www.intelliwolf.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.intelliwolf.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.intelliwolf.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.intelliwolf.com\/wp-json\/wp\/v2\/comments?post=1984"}],"version-history":[{"count":1,"href":"https:\/\/www.intelliwolf.com\/wp-json\/wp\/v2\/posts\/1984\/revisions"}],"predecessor-version":[{"id":1987,"href":"https:\/\/www.intelliwolf.com\/wp-json\/wp\/v2\/posts\/1984\/revisions\/1987"}],"wp:attachment":[{"href":"https:\/\/www.intelliwolf.com\/wp-json\/wp\/v2\/media?parent=1984"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.intelliwolf.com\/wp-json\/wp\/v2\/categories?post=1984"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.intelliwolf.com\/wp-json\/wp\/v2\/tags?post=1984"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}