I have set up a custom field which you add the end of a youtube link in through a text widget in wordpress from there a function adds this to an iframe in the url.
Below is the function adding this to the page:
<?php if (($videoUrl = get_field('video_name', $post->ID)) != '') {
//Extract the url arguments (everything after the '?'
if (($query = parse_url($videoUrl, PHP_URL_QUERY)) != '') {
//Convert the arguments into an array for each access
parse_str($query, $arguments);
if (array_key_exists('v', $arguments)) {
//Create the embed code using the id from the 'v' argument
$videoId = $arguments['v'];
?>
<div class="videoContainer">
<iframe width="390" height="219" src="https://www.youtube.com/embed/<?= $videoId ?>?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
</div>
<?php
}
}
} ?>
I have added this in with the content however nothing seems to be displaying still. Could someone please help me spot any bugs..
Youtube video show in wordpress template using advanced custom field
1) create text field in acf.
example : text field name is video_url
2) Please enter a youtube video link in acf text field.
3) show anywhere in wordpress template page