get_header_video_url()
Gets the URL of the video header specified in the settings (customizer).
The function retrieves the link to a local video; if it is not available but there is a link to an external video, it will return that link. It will return false if there is no video at all.
Since version 4.7, it became possible to set a header video, in addition to the header image.
This function is the basis for checking: whether there is a video for the header - has_header_video()
Use the_header_video_url() when you need to output the URL directly to the screen.
Used By: has_header_video(), the_header_video_url()
Hooks from the function
Returns
String|false. URL of the video or false.
Usage
get_header_video_url();
Examples
#1 Display the header video if there is one
$url = get_header_video_url();
if( $url ){
echo wp_video_shortcode( array(
'src' => $url,
'poster' => '',
'height' => 400,
'width' => 600,
) );
}
The result will be the following HTML code:
<div style="width:600px;" class="wp-video">
<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->
<video class="wp-video-shortcode" id="video-298-1" width="600" height="400" preload="metadata" controls="controls">
<source type="video/mp4" src="http://example.com/wp-content/uploads/2017/01/polina.mp4?_=1" />
<a href="http://example.com/wp-content/uploads/2017/01/polina.mp4">http://example.com/wp-content/uploads/2017/01/polina.mp4</a>
</video>
</div>
Changelog
| Since 4.7.0 | Introduced. |