I have this function to convert any YouTube URL in any post or page to embed :-
function embed_youtube_an($post_content) { global $posts; //preg_match('|http://www.youtube.com/watch?v=([a-zA-Z0-9]+)|', $posts->post_content, $matches); preg_match('#http://w?w?w?.?youtube.com/watch\?v=([A-Za-z0-9\-_]+)#s', $posts->post_content, $matches); if (!empty($matches[1])) { $post_content = '<object width="415" height="250">'; $post_content .= '<param name="movie" value="http://www.youtube.com/v/' . $matches[1] . '&hl=en_US&fs=1&"></param>'; $post_content .= '<param name="allowFullScreen" value="true"></param>'; $post_content .= '<param name="allowscriptaccess" value="always"></param>'; $post_content .= '<embed src="http://www.youtube.com/v/' . $matches[1] . '&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="415" height="250"></embed>'; $post_content .= '</object>'; $post_content = $post_content; } return $post_content; } add_filter('the_content', 'embed_youtube_an'); But when open post , all YouTube URL does not show in embed.
Where are the problem?