Using WordPress ‘in_admin_header’ PHP action

The in_admin_header WordPress action fires at the beginning of the content section in an admin page.

Usage

add_action('in_admin_header', 'your_custom_function_name');
function your_custom_function_name() {
  // your custom code here
}

Parameters

  • None

More information

See WordPress Developer Resources: in_admin_header

Examples

Displaying a welcome message in the admin header

Add a welcome message to the admin header.

add_action('in_admin_header', 'display_welcome_message');
function display_welcome_message() {
  echo '<p><strong>Welcome to your admin dashboard!</strong></p>';
}

Add a custom logo to the admin header.

add_action('in_admin_header', 'add_custom_admin_logo');
function add_custom_admin_logo() {
  echo '<img src="path/to/your/logo.png" alt="Custom Admin Logo" />';
}

Adding a custom navigation menu

Add a custom navigation menu to the admin header.

add_action('in_admin_header', 'add_custom_navigation_menu');
function add_custom_navigation_menu() {
  echo '<nav class="custom-nav-menu">';
  echo '<ul>';
  echo '<li><a href="#">Menu Item 1</a></li>';
  echo '<li><a href="#">Menu Item 2</a></li>';
  echo '</ul>';
  echo '</nav>';
}

Displaying a notification banner

Display a notification banner in the admin header.

add_action('in_admin_header', 'display_notification_banner');
function display_notification_banner() {
  echo '<div class="notification-banner">';
  echo '<p>Important: Update your settings!</p>';
  echo '</div>';
}

Adding custom CSS to the admin header

Add custom CSS styles to the admin header.

add_action('in_admin_header', 'add_custom_admin_css');
function add_custom_admin_css() {
  echo '<style>
    .custom-nav-menu {
      background-color: #f1f1f1;
      padding: 10px;
    }
  </style>';
}