Admin & Dashboard PHP Beginner

Add Your Own CSS to wp-admin

Load a few lines of your own CSS on every admin page, to hide clutter or match your brand.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 11 lines
add_action( 'admin_enqueue_scripts', function (): void {
	$css = '
		/* Example: hide the "Screen Options" tab on the dashboard. */
		.index-php #screen-options-link-wrap { display: none; }

		/* Example: brand-coloured primary buttons. */
		.wp-core-ui .button-primary { background: #6F58CA; border-color: #6F58CA; }
		.wp-core-ui .button-primary:hover { background: #5B45B8; border-color: #5B45B8; }
	';
	wp_add_inline_style( 'common', $css );
} );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

Sometimes the fastest fix in wp-admin is a little CSS: hiding a confusing setting, tidying a plugin’s screen or adding your brand colour. This snippet adds your CSS to every admin page the proper way.

How it works

On admin_enqueue_scripts, wp_add_inline_style() attaches your CSS to common, the stylesheet WordPress loads on every admin page. It’s printed right after that file, so your rules win without needing !important.

Body classes such as .index-php (dashboard) or .post-type-product let you target a single screen.

Things to watch

  • Hiding a setting with CSS doesn’t remove it. Use capabilities or the snippet that hides menu items when you need to stop access.
  • Admin styles can change between WordPress versions. Check your CSS after major updates.

How to test it

Reload any admin page. Primary buttons should use your brand colour.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only