サポート » 使い方全般 » 個別記事のときだけYoutubeの動画を表示させたい

  • ○質問の主旨

    個別記事が表示されたときだけ、
    投稿したYoutubeの動画を表示させたいと考えております。

    その際、条件分岐タグである、

    <?php (is_single()): ?>
    <?php endif; />
    を使おうと考えております。

    この条件分岐タグの中で
    どのようなコードの記述をすればよいでしょうか?

    お詳し方ご教示よろしくお願いします。

    ○質問の補足

    <?php (is_single()): ?><?php endif; />
    を使おうと考えているファイルはcontent-single.phpです。
    そのはcontent-single.phpを呼び出すファイルは、single.phpです。

    また、Youtubeの動画は、
    「投稿」→「投稿の編集」よりURLコードを
    直接記述しています。

    (貼り付けの例)
    http://youtu.be/2H0g5uIjr_8

    ○コード

    (content-single.php)

    <div class="post">
    	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    		<p class="postcat"><?php the_category(' '); ?></p>
    
    		<p class="youtube">
    		<?php is_single(): ?>
    			// youtubeの動画を出力するためのコード
    		<?php endif; ?>
    		<p class="postcontent"><?php the_content(); ?></p>
    		<p class="postinfo"><?php echo get_the_date(); ?></p>
    </div>

    (single.php)

    <?php get_header(); ?>
    <!-- コンテンツ -->
    <div id="content">
    <?php if(have_posts()): while(have_posts()): the_post(); ?>
    		<?php get_template_part('content','single'); ?>
    
    	<p class="pagenation">
    		<span class="oldpage"><?php previous_post_link(); ?></span>
    		<span class="newpage"><?php next_post_link(); ?> </span>
    	</p>
    <?php endwhile; endif; ?>
    
    <?php get_template_part('pagenation'); ?>
    </div>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    ○関連質問

    コンテンツ(動画)の使い分け
    http://ja.forums.wordpress.org/topic/25216?replies=1#post-67043
    (

  • トピック「個別記事のときだけYoutubeの動画を表示させたい」には新たに返信することはできません。