do_action( ‘admin_head’ )

Fires in head section for all admin pages.

More Information

The common usage is to include CSS (external via <link> or inline via <style>) or JS (external and inline via <script>).

Source

do_action( 'admin_head' ); 

Changelog

VersionDescription
2.1.0Introduced.

User Contributed Notes

  1. Skip to note 4 content

    A basic example (from Hello Dolly plugin code):

    function dolly_css() {	// This makes sure that the positioning is also good for right-to-left languages	$x = is_rtl() ? 'left' : 'right';	echo "	<style type='text/css'>	#dolly {	float: $x;	padding-$x: 15px;	padding-top: 5px;	margin: 0;	font-size: 11px;	}	</style>	"; } add_action( 'admin_head', 'dolly_css' );
  2. Skip to note 5 content

    Example migrated from Codex:

    This example adds an inline CSS style to admin_head so the welcome message option from dashboard is removed; you can make and customize your own function and add it the same way.

    <?php // Add inline CSS in the admin head with the style tag function my_custom_admin_head() {	echo '<style>[for="wp_welcome_panel-hide"] {display: none !important;}</style>'; } add_action( 'admin_head', 'my_custom_admin_head' ); ?>
  3. Skip to note 6 content

    Example migrated from Codex:

    In this example, console.log is added, which will only be executed on the admin side.

    <?php // Add inline JS in the admin head with the <script> tag function my_custom_admin_head() {	echo '<script type="text/javascript">console.log(\'admin script\')</script>'; } add_action( 'admin_head', 'my_custom_admin_head' ); ?>

You must log in before being able to contribute a note or feedback.