The get_custom_header_markup() WordPress PHP function retrieves the markup for a custom header. The container div will always be returned in the Customizer preview.
Usage
echo get_custom_header_markup();
Parameters
- None
More information
See WordPress Developer Resources: get_custom_header_markup()
Examples
Display custom header markup in a theme
This example demonstrates how to display the custom header markup within a theme’s header.
// In your header.php file
<div class="custom-header">
    <?php echo get_custom_header_markup(); ?>
</div>
Add custom class to the custom header markup
This example shows how to add a custom CSS class to the custom header markup.
// In your theme's functions.php file
function my_theme_custom_header_args( $args ) {
    $args['header_class'] = 'my-custom-header-class';
    return $args;
}
add_filter( 'get_custom_header_markup_args', 'my_theme_custom_header_args' );
Add custom attributes to the custom header markup
This example demonstrates how to add custom attributes to the custom header markup.
// In your theme's functions.php file
function my_theme_custom_header_args( $args ) {
    $args['header_attrs'] = array( 'data-custom-attr' => 'my-value' );
    return $args;
}
add_filter( 'get_custom_header_markup_args', 'my_theme_custom_header_args' );
Change custom header markup tag
This example shows how to change the default custom header markup tag.
// In your theme's functions.php file
function my_theme_custom_header_args( $args ) {
    $args['header_tag'] = 'header';
    return $args;
}
add_filter( 'get_custom_header_markup_args', 'my_theme_custom_header_args' );
Modify custom header markup using a filter
This example demonstrates how to modify the custom header markup using the get_custom_header_markup filter.
// In your theme's functions.php file
function my_theme_modify_custom_header_markup( $markup ) {
    return '<div class="modified-custom-header">' . $markup . '</div>';
}
add_filter( 'get_custom_header_markup', 'my_theme_modify_custom_header_markup' );