Dynamically Embed Youtube Video in ACF Field in Gutenberg

, ,

YouTube video

Written By

Jonathan Jernigan

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' );

Signup for the most inconsistent newsletter this side of the Mississippi

Delivered on a regular-as-I-can basis, I'll share with you the tl;dr of new blog posts and videos, exciting announcements, and other valuable information from around the WordPress ecosphere. You'll never get more than one email per week from me.

"*" indicates required fields

This field is for validation purposes and should be left unchanged.