Created
August 16, 2019 21:41
-
-
Save CFranc111/b284aa2475aa676ece215dd35a7f9246 to your computer and use it in GitHub Desktop.
Failed attempt - replace ACF YouTube URL with nocookie URL
This file contains hidden or 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
function miunus6db_youtube_nocookie( $post_id ) { | |
if( get_field('video', $post_id) ) { | |
$url = get_field('video', $post_id, false); | |
$url = str_replace( 'youtube.com/watch?v=', 'youtube-nocookie.com/embed/', get_field('video', $post_id, false)); | |
update_field('video', $url, $post_id); | |
} | |
} | |
add_action('acf/save_post', 'miunus6db_youtube_nocookie', 25); |
Put something like this in template:
<?php
$iframe = get_field('video');
$iframe = str_replace('youtube.com/embed/', 'youtube-nocookie.com/embed/', $iframe);
?>
<div class="minus6db-video"><?php echo $iframe ?></div>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also fails, with same result: