Using WordPress ‘is_header_video_active()’ PHP function

The is_header_video_active() WordPress PHP function checks whether the custom header video is eligible to show on the current page.

Usage

$is_video_active = is_header_video_active();

This will return true if the header video is active, otherwise false.

Parameters

  • None

More information

See WordPress Developer Resources: is_header_video_active()

Examples

Show header video only if active

This example checks if the header video is active before displaying it on the page.

if ( is_header_video_active() ) {
    the_custom_header_markup();
}

Display alternative content if header video is not active

This example displays alternative content if the header video is not active on the current page.

if ( is_header_video_active() ) {
    the_custom_header_markup();
} else {
    echo '<img src="path/to/alternative/image.jpg" alt="Alternative Content">';
}

Add a class to the header element based on header video status

This example adds a CSS class to the header element depending on whether the header video is active or not.

<header class="<?php echo is_header_video_active() ? 'header-video-active' : 'header-video-inactive'; ?>">
    <!-- Header content here -->
</header>

Display a message to users when header video is not active

This example displays a message to the users when the header video is not active on the current page.

if ( !is_header_video_active() ) {
    echo '<p>The header video is not active on this page.</p>';
}

Add a custom action based on header video status

This example triggers a custom action in your theme or plugin when the header video is not active.

if ( !is_header_video_active() ) {
    do_action( 'my_custom_action' );
}