Created
February 24, 2019 14:12
-
-
Save dospuntocero/cdb0acd13b40828022cd5b115dd0e566 to your computer and use it in GitHub Desktop.
i need to get just the id from a youtube link using an oembed field from advanced custom fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$vf = get_sub_field( 'videolink' ); | |
preg_match('/src="(.+?)"/', $vf, $matches); | |
$vf = end(explode('/', reset(explode('?', $matches[1])))); | |
?> | |
<?php if($vf): ?> | |
<a class="button button__play js-modal-btn" href="#" data-video-id="<?php echo $vf; ?>">Watch</a> | |
<? endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment