AdvancedCustomField:wordpressでカスタムフィールドを使って投稿に紐づいた動画を取得して一覧で表示させる。

WP_Queryを作ってwp_oembed_getでコードを出力、あわせて出力コードを加工する感じ。
あとはレスポンシブをどうするかやなぁ。
にしてもAdvancedCustomField便利だなぁ。

[php]
$args = array(
‘post_type’ => ‘hoge’, // カスタム投稿タイプの名前
‘meta_key’=>’movie_url’, //カスタムフィールドのフィールド名
‘meta_value’=>’null’, //カスタムフィールドの値
‘meta_compare’ => ‘!=’ //空ではない
);
$the_query = new WP_Query($args);
/*movie_urlの含まれるカスタム投稿から動画のみ抽出 */
if($the_query->have_posts()){

while ( $the_query->have_posts() ) : $the_query->the_post();
get_the_title($post->ID);
$url = get_field("movie_url", $post->ID);
$embed_code = wp_oembed_get( $url, array( ‘width’ => 320 ) );//とりあえずembedタグ上でサイズを決めておいた
$embed_code = preg_replace("@src=([‘\"])?([^’\">\s]*)@", "src=$1$2&showinfo=0&rel=0", $embed_code); //コードを整形、第二引数でお好みのスイッチつける
echo $embed_code;
endwhile;
[/php]

参考
WordPressで、カスタムフィールドが特定の値の記事のリストを作成する

wp_oembed_get:WordPress私的マニュアル

Modify Youtube Oembed URLs to remove showinfo and more