get_header

Load header template.

Description

get_header( (null) $name = null ); 

Includes the header template for a theme or if a name is specified then a specialised header will be included.

For the parameter, if the file is called header-special.php then specify "special".

Parameters (1)

0. $name — Optional. (null) => null
The name of the specialised header.

Usage

  1. if ( !function_exists( 'get_header' ) ) { 
  2. require_once ABSPATH . WPINC . '/general-template.php'; 
  3.  
  4. // The name of the specialised header. 
  5. $name = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_header($name); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/general-template.php  
  1. function get_header( $name = null ) { 
  2. /** 
  3. * Fires before the header template file is loaded. 
  4. * The hook allows a specific header template file to be used in place of the 
  5. * default header template file. If your file is called header-new.php,  
  6. * you would specify the filename in the hook as get_header( 'new' ). 
  7. * @since 2.1.0 
  8. * @since 2.8.0 $name parameter added. 
  9. * @param string|null $name Name of the specific header file to use. null for the default header. 
  10. */ 
  11. do_action( 'get_header', $name ); 
  12.  
  13. $templates = array(); 
  14. $name = (string) $name; 
  15. if ( '' !== $name ) { 
  16. $templates[] = "header-{$name}.php"; 
  17.  
  18. $templates[] = 'header.php'; 
  19.  
  20. locate_template( $templates, true );