YouTube Video Importer from CodeCanyon

Posted in: Newspaper
Post count: 3

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.
Post count: 3343

Hey,
Thanks for this! Added to our documentation at From the Forum section

Post count: 3

HI, im newbie, I dont know where to put these code. Can someone tell me which file i need to edit? and where to put those code in? Thanks in advance.

Post count: 3343

Hi,

@leolion84
Add the code in function.php file.

Post count: 61

Hi, I just purchased it. looks ok, but it imports videos as youtu.be instead of youtube.com

So it does not work in the featured video.

Thank you for helping

Post count: 61

ok, just need to change this line in the code above

$postarray["td_video"] ="http://youtu.be/".$video['video_id'];

to

$postarray["td_video"] ="http://www.youtube.com/watch?v=".$video['video_id'];

Thank you

Post count: 6600

Thanks @dalandau for sharing, glad you managed to figure that out.

Post count: 133

its working for me without additional job as you mentioning however automatic import doesnt workj your are right and this could solve it..

Viewing 8 posts - 1 through 8 (of 8 total)
The forum ‘Newspaper’ is closed to new topics and replies.