Show Youtube video from WP YouTube Lyte plugin

If you are using this plugin WP YouTube Lyte to embed Youtube video to your post, Content Views Pro will not able to detect Youtube video url, because that plugin uses httpv as protocol for url.

To solve this problem, please add this code to file functions.php of your active theme:

// Content Views Pro - Fix problem with WP YouTube Lyte
add_filter( 'pt_cv_custom_media_thumbnail', 'cvp_theme_custom_media_thumbnail_ytl', 10, 2 );
function cvp_theme_custom_media_thumbnail_ytl( $args, $post_content ) {
	preg_match_all( '|http[sv]?://[^\s"\']+|im', $post_content, $matches );
	if ( isset($matches[0][0]) ) {
		$matches[0][0] = str_replace( 'httpv', 'http', $matches[0][0] );
		$args = $matches;
	}

	return $args;
}

Best regards,

Scroll to Top