The admin_head WordPress PHP action is used to add custom code in the head section of all admin pages.
Usage
add_action('admin_head', 'your_custom_function'); function your_custom_function() { // your custom code here }
Parameters
None
More information
See WordPress Developer Resources: admin_head
Examples
Add custom CSS to all admin pages
This code adds a custom CSS file to the head section of all admin pages.
add_action('admin_head', 'add_custom_admin_css'); function add_custom_admin_css() { echo '<link rel="stylesheet" href="' . get_template_directory_uri() . '/admin-styles.css" />'; }
Add inline CSS to all admin pages
This code adds inline CSS to the head section of all admin pages.
add_action('admin_head', 'add_inline_admin_css'); function add_inline_admin_css() { echo '<style>.custom-admin-class { color: red; }</style>'; }
Add custom JavaScript to all admin pages
This code adds a custom JavaScript file to the head section of all admin pages.
add_action('admin_head', 'add_custom_admin_js'); function add_custom_admin_js() { echo '<script src="' . get_template_directory_uri() . '/admin-scripts.js"></script>'; }
Add inline JavaScript to all admin pages
This code adds inline JavaScript to the head section of all admin pages.
add_action('admin_head', 'add_inline_admin_js'); function add_inline_admin_js() { echo '<script>console.log("Custom admin script");</script>'; }
Add custom meta tag to all admin pages
This code adds a custom meta tag to the head section of all admin pages.
add_action('admin_head', 'add_custom_admin_meta'); function add_custom_admin_meta() { echo '<meta name="custom-meta" content="Custom Meta Content">'; }