the_header_video_url()
Displays header video URL specified in theme Customizer (theme settings).
Displays a link to a local or an external video. Displays nothing if there is no video.
Use get_header_video_url() to get a header video URL for further processing.
You can learn more about video headers here
Uses: get_header_video_url()
No Hooks.
Returns
null. Nothing (null).
Usage
<?php the_header_video_url(); ?>
Examples
#1 Display HTML video tag
Check whether a header video is set to not display an empty video tag:
<?php if( has_header_video() ){ ?>
<video class="wp-video-shortcode" id="video-298-1" width="600" height="400" preload="metadata" controls="controls">
<source type="video/mp4" src="<?php the_header_video_url() ?>" />
</video>
<?php } ?>
Changelog
| Since 4.7.0 | Introduced. |
the_header_video_url() the header video url code WP 6.9.1
function the_header_video_url() {
$video = get_header_video_url();
if ( $video ) {
echo esc_url( $video );
}
}