Hi all,
Thought I’d share a great tool with you all. I found this YouTube wordpress plugin from CodeCanyon that I use as a bulk youtube video importer.
It is at: http://codecanyon.net/item/youtube-wordpress-plugin-video-import/4429742
To use it properly, you will need to add two functions, one in the parent theme and one in any child theme that you are using. I used the code the plugin developers provided in the documentation and modified it for the Newspaper theme to make it compatible with the plugin.
Once done, the import feature save a tremendous amount of time going to YouTube and searching for stuff to put into the site. With the function additions, the YouTube videos will be imported directly as your posts.
The Code:
—-Place in child theme—-
// YouTube plugin functionality
/**
* Add theme compatibility
* @param array $themes - array of default compatible themes
*/
function newspaper_child_theme_compat( $themes ){
$themes['newspaper child theme'] = array(
'post_type' => 'post',
'taxonomy' => false,
'post_meta' => array(
'embed' => 'cb_video_embed_code_post'
),
'post_format' => 'video',
'theme_name' => 'Newspaper child theme'
);
return $themes;
}
add_filter('cbc_youtube_theme_support', 'newspaper_child_theme_compat');
—Place in Parent Theme—-
/**
* Add theme compatibility
* @param array $themes - array of default compatible themes
*/
function newspaper_theme_compat( $themes ){
$themes['newspaper'] = array(
'post_type' => 'post',
'taxonomy' => false,
'post_meta' => array(
'embed' => 'tie_embed_code'
),
'post_format' => 'video',
'theme_name' => 'Newspaper'
);
return $themes;
}
add_filter('cbc_youtube_theme_support', 'newspaper_theme_compat');
/**
* On bulk post import, set up all extra fields needed by the theme to flag post as video
* @param int $post_id - ID of newly created post
* @param array $video - array of video data returned by YouTube
* @param false/array $theme_import - theme import configuration
*/
function newspaper_post_fields( $post_id, $video, $theme_import ){
// check if setting is to import as theme post
if( !$theme_import ){
return;
}
$postarray["td_video"] ="http://youtu.be/".$video['video_id'];
update_post_meta($post_id, 'td_post_video', $postarray );
}
add_action('cbc_post_insert', 'newspaper_post_fields', 10, 3);
——– End Of Code ————
Hope you guys find this useful.
-
This topic was modified 11 years by
Marius.