Site logo

Archived topic

Youtube Video Block before navigation

2 replies · Started by Guillermo on August 23, 2022

Viewing posts 1–3 of 3

Hi,
I would like to add a youtube video block before navigation on the main page but for some reason it doesn't work.
What I've done is create a hook element (before header) with a container and a youtube block inside it with the url I want to.

I've already tried the tutorial to use Page Hero backgroung , but I want to try this method and see how it looks.

Website: https://arcillasoliete.com/

Thanks.

Hi Guillermo,

Solution 1:

Use this PHP code. Adding PHP: https://docs.generatepress.com/article/adding-php/

add_filter( 'generate_do_block_element_content', function( $content ) {
    global $wp_embed;
    $content = $wp_embed->autoembed( $content );
	
    return $content;
} );

Solution 2:

Go to this website, paste the video URL there, and copy the generated Embed code.
https://embedresponsively.com/

Then paste the embed code to an HTML block in the block element.

Yeah!, that works perfectly, many thanks.

This archived topic is closed to new replies.