doulai5585 2012-03-25 02:34
浏览 32
已采纳

如果自定义字段包含YouTube ID,WordPress将显示YouTube视频

I'm working on pizzli.com/darrenwp. I've created a featured content slider using Jquery/Jquery UI and a custom field called youtubeid. What I am trying to do is display the YouTube Video if the youtubeid custom field contains a YouTube ID and if it doesn't I want to display the Post's featured image. I've got this working on the post pages, but not with the Jquery slider. Any support would be highly appreciated. Here's the code that I am trying to use: ">">

    <!-- First Content -->
    <?php $x=0 ?>
    <?php query_posts("showposts=4&category_name=Popular News"); $i = 1; ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php $x++ ?>
    <?php $youtubeid = get_post_meta($post->ID, "youtubeid", true); ?>
    <div id="fragment-<?php echo ($x);?>" class="ui-tabs-panel" style="">
    <?php if($youtubeid !=='') { ?>
<?php echo "<iframe width='400' height='250' src='http://www.youtube.com/embed/'"?><?php echo ($youtubeid) ?> <?php echo "frameborder='0' allowfullscreen></iframe>"?>
        <?php } ?>
         <div class="info" >

         </div>         
         <h2><a class="title" rel="bookmark" href="<?php the_permalink() ?>"><?php the_title();?> </a></h2>
            <p><?php the_excerpt(); ?><a class="title" rel="bookmark" href="<?php the_permalink() ?>">Read more</a></p>
            <?php echo ($youtubeid); ?>
    </div>
    <?php endwhile; ?>

</div>
  • 写回答

1条回答 默认 最新

  • dongtan5811 2012-03-25 04:05
    关注

    Your iframe code would need to look like this

    <?php echo "<iframe width='400' height='250' src='http://www.youtube.com/embed/".$youtubeid."' frameborder='0' allowfullscreen></iframe>" ?>
    

    You terminated your src tag with closing it with ' too early

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办