Dynamically Embed Youtube Video in ACF Field in Gutenberg

GenerateBlocks - GeneratePress - Gutenberg

August 16, 2022

YouTube video

This video will teach you how to show a YouTube video URL inside of an ACF field on the frontend of your Gutenberg site, without having to manually copy and paste the links into a video component.

In my case, I’m using GeneratePress and GenerateBlocks and wanted the URL to be dynamically shown on the front end.

Code:

function yt_video_shortcode() { 
 
    $myfield = get_field('video_url');
     
    return $myfield;
     
}
add_shortcode( 'ytvideo', 'yt_video_shortcode' );

Join the Inside Link Community

Get access to all courses, weekly office hours, live build sessions, and an active community of WordPress professionals.

Learn More →