Skip to content

Instantly share code, notes, and snippets.

@jdevalk
Last active December 10, 2015 22:28
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 jdevalk/0641e42ef304370bc864 to your computer and use it in GitHub Desktop.
Save jdevalk/0641e42ef304370bc864 to your computer and use it in GitHub Desktop.
This takes the youtube video ID stored in a custom field and adds a full Youtube URL to the content to allow the video plugin to easily index it.
<?php
/**
* Takes the youtube video ID stored in a custom field and adds a full Youtube URL to the content to allow
* the video SEO plugin to index it.
*
* The video URL is added to the top of content to make it override other video's in the post.
*
* @param string $content the input content field.
* @param array $vid the video array for the post.
*
* @return string $content
*/
function fix_content_input( $content, $vid ) {
$youtube_id = get_post_meta( $vid['post_id'], 'video', true );
$content = "\n" . 'http://youtube.com/v/'. $youtube_id . "\n" . $content;
return $content;
}
add_filter( 'wpseo_video_index_content', 'fix_content_input', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment