WordPress at a glance

the_header_video_url() WP 4.7.0

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

Works based on: get_header_video_url()

No Hooks.

Return

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 } ?>

Code of the header video url: wp-includes/theme.php WP 5.2.2

<?php
function the_header_video_url() {
	$video = get_header_video_url();
	if ( $video ) {
		echo esc_url( $video );
	}
}

Related Functions

From tag: custom_header (theme options: video color image)

More from category: Other Theme Functions

No comments
    Hello, !     Log In . Register