Custom Fields PHP NOOB!
-
Gretings all.
Right now i use wordpress and in my post i can add a Video by entering the Youtube address into a Custom field called “video_url” and then it outputs the video on my site wich works easy, here it is:
<div class="video"> <html><center> <?php $meta_value = get_post_meta($post->ID, 'video_url', true); if($meta_value){ $url = parse_url($meta_value); $id = 0; if($url['host'] == 'youtu.be'){$id = ltrim($url['path'],'/');} else if(strpos($url['path'],'embed') == 1){$id = end(explode('/',$url['path']));} else{parse_str($url['query']);$id = $v;} echo '<p><iframe width="540" height="355" frameborder="1" allowfullscreen="true" src="https://www.youtube.com/embed/'.$id. '?version=3&theme=light&fs=1&rel=0&cc_load_policy=1&iv_load_policy=1&modestbranding=1" type="application/x-shockwave-flash" allowScriptAccess="always" allowfullscreen="true" width="600" height="355"> </iframe></p>'; } ?> </div>
However i am tring to add this Modification here in wich adding the video link custom field will also bring back the youtube video title and descripiton,
<?php $video_id = ’48J_DIZBNyE’; $video_info = simplexml_load_file(‘https://gdata.youtube.com/feeds/api/videos/’.$video_id.’?v=1′); echo $video_info->title . ‘<hr>’; // title echo $video_info->content; // description ?>
Could anyone please help me implement the bottom code with the top piece of code !!
Mucg respect
Thanks
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Custom Fields PHP NOOB!’ is closed to new replies.