php - Youtube link parsing in wordpress


I'm trying to parse a youtube link using this code:

$url = '';
$parsed_url = parse_url($url);
parse_str($parsed_url['query'], $parsed_query);
echo '<iframe src="' . $parsed_query['v'] . '" type="text/html" width="400" height="300" frameborder="0"></iframe>';

It seems fine if$url is hardcoded. But if I add a link using WordPress admin panel, I get an empty variable.




Try it this way:$url = get_post_meta( $post->ID, 'video_src', true );

People are also looking for solutions to the problem: print key of first element of array_search() in php


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.