Skip to content

Instantly share code, notes, and snippets.

@lepittenger
Last active September 22, 2017 19:11
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 lepittenger/35b4ae5ba62328dc0f95dc3f0bd33189 to your computer and use it in GitHub Desktop.
Save lepittenger/35b4ae5ba62328dc0f95dc3f0bd33189 to your computer and use it in GitHub Desktop.
Take a link from a video and embed it before the post content with Genesis
<?php
/**
* Add video from a custom field before the post content on single posts.
*/
add_action( 'genesis_entry_content','lp_video_before_entry_content_on_singles', 5 );
function lp_video_before_entry_content_on_singles() {
if ( is_singular() ) {
// get the video from the custom field the standard WordPress way, even if using ACF
$video_url = get_post_meta( get_the_ID(), 'video_url', true );
if ( $video_url ) {
echo wp_oembed_get( esc_url( $video_url ), array( 'width' => 680 ) );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment