# Remind Editors to Add Captions to Videos

> Shows a warning after saving when a post contains a Video block without a captions or subtitles track, so videos are not published without captions by accident.

- Type: PHP
- Runs: Run everywhere
- Category: [Accessibility](https://wpide.com/library/category/accessibility/)
- Tags: video, captions, admin-notice
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/a11y-video-caption-reminder/

## Code

```php
add_action( 'save_post', function ( $post_id, $post ) {
    if ( wp_is_post_revision( $post_id ) || ! has_block( 'core/video', $post ) || ! current_user_can( 'edit_post', $post_id ) ) {
        return;
    }

    $missing = 0;

    foreach ( parse_blocks( $post->post_content ) as $block ) {
        if ( 'core/video' === $block['blockName'] && empty( $block['attrs']['tracks'] ) ) {
            $missing++;
        }
    }

    if ( $missing ) {
        set_transient( 'wpide_caption_notice_' . get_current_user_id(), $missing, MINUTE_IN_SECONDS );
    }
}, 20, 2 );

add_action( 'admin_notices', function () {
    $key     = 'wpide_caption_notice_' . get_current_user_id();
    $missing = (int) get_transient( $key );

    if ( ! $missing ) {
        return;
    }

    delete_transient( $key );
    printf( '<div class="notice notice-warning is-dismissible"><p>%s</p></div>', esc_html( sprintf( '%d video(s) in this post have no captions track. Add one in the Video block settings under "Text tracks".', $missing ) ) );
} );
```

## Notes

Add captions in the Video block settings under "Text tracks"; embedded YouTube and Vimeo videos manage captions on their own platform.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remind Editors to Add Captions to Videos" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
