我想循环通过WordPress中的猫头鹰旋转木马,我使用了这个代码,但都不起作用

时间:2019-02-25 作者:jozef koko
<div class="container">
   <div class="row">
     <div class="col-md-12">
        <div class="owl-carousel"  id="product-slider">
          <?php while ($loop->have_posts()): $loop->the_post();?>
              <div class="product">
            <?php $loop = new wp_Query(array(
           \'post_type\' => \'home_producten\',
           \'orderby\' => \'post_id\',
            \'order\' => \'ASC\',
            ));?>
           <?php if (has_post_thumbnail()) { // check for Image
            the_post_thumbnail();}?>
            <h3 class="title">
            <?php the_title();?>
            </h3>
            <p class="description">
            <?php the_content();?>
            </p>
            <a class="btn btn-warning text-uppercase" href="<?php 
           the_permalink();?>">
            See More
            </a>
         </div>
        <?php endwhile;?>
      </div>
   </div>

 </div>
 <!-- ==== END OF CAROUSEL ===== -->

1 个回复
SO网友:Tanmay Patel

这里您使用了虚拟图像,但可以看到结果。滑块工作正常。https://www.risingwebstars.com/video.webm 上面的代码有两个错误,所以请使用下面的代码。

<div class="container">
  <div class="row">
    <div class="col-md-12">
      <div class="owl-carousel" id="product-slider">
        <?php $loop = new wp_Query(array(
           \'post_type\' => \'home_producten\',
           \'orderby\' => \'ID\',
            \'order\' => \'ASC\',
        )); ?>
        <?php while ($loop->have_posts()): $loop->the_post(); ?>
        <div class="product">
          <?php if(has_post_thumbnail()){ the_post_thumbnail(); } ?>
          <h3 class="title">
            <?php the_title(); ?>
          </h3>
          <p class="description">
            <?php the_content(); ?>
          </p>
          <a class="btn btn-warning text-uppercase" href="<?php the_permalink(); ?>"> See More </a> </div>
        <?php endwhile;?>
      </div>
    </div>
  </div>
</div>
使用下面的脚本,因为我在此脚本中发现了一个问题jsfiddle.net/Youssef_X/omfLuk82/15

<script type="text/javascript">
jQuery(document).ready(function () {
  jQuery("#product-slider").owlCarousel({
    loop: true,
    items: 3,
    itemsDesktop: [1000, 3],
    itemsDesktopSmall: [979, 2],
    itemsTablet: [768, 2],
    itemsMobile: [650, 1],
    margin: 10,
    nav: true,
    autoPlay: true,
    dots: false,
    autoHeight: false,
  });
});
</script>

相关推荐

Sidebar slideshow widget

有人知道可以放在边栏上的高质量图像幻灯片小部件吗?