새로운 Wordpress Youtube 틈새 테마에서 몇 가지 작업을 시도합니다. 사용자가 Youtube watch를 입력 할 수있는 탭이 있습니까? v = xxxxxxxxxxx id. 그들이 xxxxxxxxxxx url을 입력하면 동영상을 출력하고 '루프'쿼리를 통해 탭 당 16 개의 게시물을 표시합니다.Youtube Get thumbnail
작동 예는 here
나는이 구글 개발자 콘솔 API를 가지로 보았다 ... 그것은 나에게 완전한 횡설수설이다. 내 사이트에서 볼 수있는 4 가지 카테고리에 맞춤 게시물 유형을 사용하고 있습니다. 지금 "코메디"만 채워집니다.
새 편집 :이 작품. 이 점을 이해하는 데 도움을 준 모든 분들께 감사드립니다!
<?php
$new_query = new WP_Query();
$new_query->query(array('post_type' => array('comedy'), 'orderby' => 'title', 'order' => 'asc','showposts' => 16, 'paged'=>$paged));
while ($new_query->have_posts()) : $new_query->the_post();
$url = get_post_meta ($post->ID, 'comedy_url', $single = true);
include(TEMPLATEPATH . '/library/variables.php');
$code = 'http://www.youtube.com/watch?v=' . $url;
$json = file_get_contents('http://www.youtube.com/oembed?url='.urlencode($code));
$video = json_decode($json);
?>
<img src="<?php echo $video->thumbnail_url ?>" />
미리보기 이미지를 가져올 때 일부 사용자는 미리보기 이미지의 위아래에 검은 색 테두리가 나타날 수 있습니다.
<a href="<? if($code) {?><?php echo $code; ?><? } ?>">
<div class="yt-thumbnail" style="background:url('<?php echo $video->thumbnail_url ?>') center no-repeat;"></div>
</a>
// in your css file
.yt-thumbnail{
height: 164px;
width: 300px;
background-size: 300px 220px;
}
가 ... 어떻게이 JSON FTP를 해제 파일을 잡아합니까? 내가 할 수 있다고 가정합니다. 'http://www.youtube.com/oembed?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv% if ($ url) {?> php echo $ url; ?> } ?>' 그러나 미리보기 이미지를 가져 와서 호출하면 어떻게 될까요? – FlannelBeard
참조 : http://stackoverflow.com/questions/15617512/get-json-object-from-url –
발견 [this] (http://stackoverflow.com/questions/10377244/how-to-correctly-use) -에서 - 당겨 - 엄지 - 투 - 유튜브)뿐만 아니라 ... 그것을 조사. – FlannelBeard