Created
September 18, 2013 18:25
-
-
Save wpexplorer/6613334 to your computer and use it in GitHub Desktop.
Open Graph Video URL For Facebook - WordPress Function
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
<?php | |
// Add video open graph metatag | |
add_action( 'wp_head', 'wpex_fb_video_opengraph'); | |
function wpex_fb_video_opengraph() { | |
if ( is_singular( 'post' ) ) { | |
global $post; | |
$output=''; | |
$postid = $post->ID; | |
$format = get_post_format( $post_id ); | |
if ( $format !== 'video' ) return; // not video post format, so exit | |
$video = get_post_meta( $postid, 'wpex_post_oembed', true ); | |
if ( $video !== '' ) { | |
$output = '<meta property="og:url" content="'. $video .'" />'; | |
} | |
return $output; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment