Skip to content

Instantly share code, notes, and snippets.

@mor10
Created July 13, 2016 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mor10/727ad7a4751925ef3079995c2fe8e705 to your computer and use it in GitHub Desktop.
Save mor10/727ad7a4751925ef3079995c2fe8e705 to your computer and use it in GitHub Desktop.
Generate automatic oEmbed from URL with Advanced Custom Field
<?php
// Make sure the plugin is active
if ( function_exists( 'get_field' ) ) {
$lecture_video = get_field('lecture_video');
}
// If the current post is a Lecture post and we have a lecture video URL, use oEmbed
if ( 'lecture' === get_post_type() ) {
if ( $lecture_video ) {
echo wp_oembed_get( $lecture_video );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment