Created
November 16, 2015 03:57
-
-
Save chillybin/8b26d51a758bfac60cf7 to your computer and use it in GitHub Desktop.
For this example to work you will need to install Advanced Custom Fields, create a text field called "youtube_video_id" and then when you are creating your post, you can embed your video, and then use the ID from YouTube into the text box.
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
add_action('wp_head', 'chillybin_custom_og_image'); | |
function chillybin_custom_og_image() { | |
if (get_field('youtube_video_id')) { ?> | |
<meta property="og:image" content="http://img.youtube.com/vi/<? echo get_field('youtube_video_id'); ?>/mqdefault.jpg" /> | |
<?php } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment