# Show Only Your Own Related Videos on YouTube Embeds

> Adds rel=0 to YouTube embeds so the suggestions shown when a video ends come from the same channel instead of from other creators.

- Type: PHP
- Runs: Run everywhere
- Category: [Media](https://wpide.com/library/category/media/)
- Tags: youtube, embeds, video
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/youtube-related-from-same-channel/

## Code

```php
add_filter( 'embed_oembed_html', function ( $html ) {
    $result = preg_replace_callback( '#src="([^"]*youtube(?:-nocookie)?\.com/embed/[^"]*)"#i', function ( $m ) {
        return 'src="' . esc_url( add_query_arg( 'rel', '0', html_entity_decode( $m[1] ) ) ) . '"';
    }, $html );

    return null === $result ? $html : $result;
}, 15 );
```

## Notes

YouTube no longer allows hiding suggestions completely; rel=0 limits them to the video's own channel.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show Only Your Own Related Videos on YouTube Embeds" 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/
