Php Wordpress引导carosel图像未显示

Php Wordpress引导carosel图像未显示,php,wordpress,Php,Wordpress,我正在用Bootstrap构建我的Wordpress主题,并在导航栏正下方的首页上使用旋转木马。我找到了一个很好的方法来循环浏览这里的图片[1]: 我想在其中一个滑块区域上运行一个测试,所以我输入了第一个循环的代码,它显示了标题和摘录,但我的图像根本没有显示出来。如何解决此问题,以及什么是循环传送带中其余图像的好方法。我用我在链接中找到的代码添加了第二个循环,它弄乱了我的页面,所以我把它取了出来。这里是我到目前为止仍然拥有的一些静态内容,我也想循环使用。我将有3个图像进入旋转木马。这是我的第一个

我正在用Bootstrap构建我的Wordpress主题,并在导航栏正下方的首页上使用旋转木马。我找到了一个很好的方法来循环浏览这里的图片[1]:

我想在其中一个滑块区域上运行一个测试,所以我输入了第一个循环的代码,它显示了标题和摘录,但我的图像根本没有显示出来。如何解决此问题,以及什么是循环传送带中其余图像的好方法。我用我在链接中找到的代码添加了第二个循环,它弄乱了我的页面,所以我把它取了出来。这里是我到目前为止仍然拥有的一些静态内容,我也想循环使用。我将有3个图像进入旋转木马。这是我的第一个真正的项目与Wordpress,因为我正试图建立我的投资组合主题,所以任何帮助是感谢

<!-- Carousel
================================================== -->

<div id="myCarousel" class="carousel slide" data-ride="carousel">

   <?php
     $the_query = new WP_Query(array(
        'category_name'  => 'Home Carousel',
        'posts_per_page' => 1
     ));
     while ($the_query->have_posts() ) :
      $the_query->the_post();
      $attachment_ids[] = get_the_ID();
     endwhile;
     wp_reset_postdata();
   ?>
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <?php foreach($attachment_ids as $attachment_id_k=>$attachment_id_v ){ 
        if($attachment_id_k == 0){$class_active = 'class="active"';}
        else{$class_active = 'class=""';}
        ?>
        <li data-target="#myCarousel" <?php echo $class_active;?> data-slide-to="<?php echo $attachment_id_k;?>"></li>
    <?php } ?>
  </ol>

  <div class="carousel-inner" role="listbox">

      <div class="carousel-inner">
        <?php foreach($attachment_ids as $attachment_id_k=>$attachment_id_v ){ 
        if($attachment_id_k == 0){$class_active = 'class="item active"';}
        else{$class_active = 'class="item"';}
        ?>
    <div <?php echo $class_active;?>>
        <div class="display_table">
            <div class="display_table_cell">
            <?php 
            $default_attr = array(
                'class' => "gallery_images",
                'alt'   => 'Gallery Images',
            );
            echo wp_get_attachment_image( $attachment_id_v, 'full', 1, $default_attr );
            $image_data = get_post( $attachment_id_v );
            if($image_data->post_excerpt != ''){
            ?>
            <div class="carousel-caption my_caption">
                <p><?php echo $image_data->post_excerpt;?></p>
            </div>
            <?php }?>
            </div>
        </div>
    </div>
    <?php } ?>
  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div><!-- /.carousel -->


在您编写的代码项部分

<?php the_post_thumbnail('full');?>

但我发现在他们使用的教程链接中

<?php the_post_thumbnail('large');?>. 

你能检查一下吗。这就是您出错的原因吗?

这是工作代码

首先通过while循环获取数组中的所有post id

<?php 
$the_query = new WP_Query(array(
    'category_name'  => 'Home Carousel',
    'posts_per_page' => 1
));
while ($the_query->have_posts() ) :
    $the_query->the_post();
    $attachment_ids[] = get_the_ID();
endwhile;
wp_reset_postdata();
?>
将此javascript代码放在footer.php,因为它的引导转盘需要一些javascript来设置选项

<script type="text/javascript">
$('.carousel').carousel({
  interval: 3000
})
</script>

$('.carousel')。carousel({
间隔时间:3000
})

是否处于
无冲突
模式?WordPress和jQuery很少能一帆风顺。好的,我会调查一下。这可能是问题的一部分。我感谢你的帮助!我会在js文件中添加类似的内容吗
code
$=jQuery.noConflict(true)
code
应该为您提供有关jQuery的noConflict函数的所有需要。你只需要把jQuery包起来,我试着插入一些其他的值,但它们也不起作用。我认为参数必须根据使用的图像大小设置,但我不确定,因为我还是Wordpress的新手。哇,这很好,但我仍然无法让旋转木马工作。我编辑了上面的代码以反映新的更改。我的新WP_查询是否位于错误的位置?我是否需要为旋转木马添加主题支持?我仍然无法使旋转木马正常工作。我是否需要将jQuery排队到我的functions.php中?或者它已经包含在Wordpress中了?
<script type="text/javascript">
$('.carousel').carousel({
  interval: 3000
})
</script>