Hy im building the Trailer section, i want to get the time automate from Youtube video's...
Custom Fields
- $key="trailer"; - represents the key of the trailer Ex (http://www.youtube.com/watch?v=QiNIfGiNiOk were key= QiNIfGiNiOk)
- $key="img_trailer"; - is the img of youtube 0.jpg
- $key="time"; - is the time of the youtube videos, this i enter manual
The question "Can i make it work to retrive the youtube time automate? and how can i make the code use less query possible"
This is my code:
<?php
$recentPosts = new WP_Query();
$recentPosts-> query(array('showposts' => 4,'orderby' => 'rand', 'post_type' =>array('trailers')));
?>
<div class="art-Post" >
<div class="art-Post-tl"></div>
<div class="art-Post-tr"></div>
<div class="art-Post-bl"></div>
<div class="art-Post-br"></div>
<div class="art-Post-tc"></div>
<div class="art-Post-bc"></div>
<div class="art-Post-cl"></div>
<div class="art-Post-cr"></div>
<div class="art-Post-cc"></div>
<div class="art-Post-body">
<h2 id="titlu-descriere" class="titlu-d">Trailere care s-ar putea sa-ti placa</h2>
<div class="linie-total"></div>
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
<div class="box-trailere">
<div class="trailer-img">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Trailer film %s', 'kubrick'), the_title_attribute('echo=0')); ?>">
<img src="http://img.youtube.com/vi/<?php $key="trailer"; echo get_post_meta($post->ID, $key, true); ?>/<?php $key="img_trailer"; echo get_post_meta($post->ID, $key, true); ?>">
<span class="duration"><?php $key="time"; echo get_post_meta($post->ID, $key, true); ?></span>
</a>
</div>
<span class="trailer-title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></span>
</div>
<?php endwhile; ?>
<div class="cleared"></div>
</div>
</div>
------------------------------- UPDATE -------------------
The down code it retrive me this
stdClass Object
(
[apiVersion] => 2.1
[data] => stdClass Object
(
[updated] => 2013-02-27T18:12:03.984Z
[totalItems] => 1
[startIndex] => 1
[itemsPerPage] => 25
[items] => Array
(
[0] => stdClass Object
(
[id] => QiNIfGiNiOk
[uploaded] => 2012-11-30T18:20:08.000Z
[updated] => 2013-02-26T22:33:56.000Z
[uploader] => ramonsteck
[category] => Entertainment
[title] => After Earth - Trailer 2013
[description] => Unete www.facebook.com/Cinemovs Historias Paranormales Reales, PelĂculas de Terror Online y proximos estrenos de cine.
[thumbnail] => stdClass Object
(
[sqDefault] => http://i.ytimg.com/vi/QiNIfGiNiOk/default.jpg
[hqDefault] => http://i.ytimg.com/vi/QiNIfGiNiOk/hqdefault.jpg
)
[player] => stdClass Object
(
[default] => https://www.youtube.com/watch?v=QiNIfGiNiOk&feature=youtube_gdata_player
[mobile] => https://m.youtube.com/details?v=QiNIfGiNiOk
)
[content] => stdClass Object
(
[5] => https://www.youtube.com/v/QiNIfGiNiOk?version=3&f=videos&app=youtube_gdata
[1] => rtsp://v1.cache6.c.youtube.com/CiILENy73wIaGQnpiI1ofEgjQhMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
[6] => rtsp://v1.cache6.c.youtube.com/CiILENy73wIaGQnpiI1ofEgjQhMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
)
[duration] => 123
[aspectRatio] => widescreen
[rating] => 2.6722891
[likeCount] => 174
[ratingCount] => 415
[viewCount] => 247218
[favoriteCount] => 0
[commentCount] => 63
[accessControl] => stdClass Object
(
[comment] => allowed
[commentVote] => allowed
[videoRespond] => moderated
[rate] => allowed
[embed] => allowed
[list] => allowed
[autoPlay] => allowed
[syndicate] => allowed
)
)
)
)
)