Skip to content

Instantly share code, notes, and snippets.

@CFranc111
Created August 16, 2019 21:41
Show Gist options
  • Save CFranc111/b284aa2475aa676ece215dd35a7f9246 to your computer and use it in GitHub Desktop.
Save CFranc111/b284aa2475aa676ece215dd35a7f9246 to your computer and use it in GitHub Desktop.
Failed attempt - replace ACF YouTube URL with nocookie URL
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);
@CFranc111
Copy link
Author

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