首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WordPress:在环线外获得钉钉

WordPress:在环线外获得钉钉
EN

Stack Overflow用户
提问于 2014-09-18 20:27:19
回答 1查看 914关注 0票数 1

我正在尝试获得我的旋转木马缩略图指示符的后缩略图图像,这是在循环之外。

目前,它是设置与图像占位符,但我需要每个拇指来表示当前选定的帖子。

代码语言:javascript
复制
 <?php 
    $items = new WP_Query(array(
            'post__in' => get_option('sticky_posts'),
            'caller_get_posts' => 1,
    'posts_per_page' => 10,
    'meta_key' => '_thumbnail_id'
    ));
    $count = $items->found_posts;
    ?>
              <div id="myCarousel" class="carousel slide" data-ride="carousel"> 

                <!-- Wrapper for slides -->
                <div class="carousel-inner">
                  <?php 
            $ctr = 0;
            while ( $items->have_posts() ) :
              $items->the_post();
              $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
              $custom = get_post_custom($post->ID);
              $link = $custom["more-link"][0];
              $class = $ctr == 0 ? ' active' : '';
            ?>
                  <div class="item<?php echo $class; ?>" id="<? the_ID(); ?>">
                    <?php the_post_thumbnail( 'full', array (
                    'class' => 'img-responsive'
                    )); ?>
                    <div class="carousel-caption">
                      <h3><a href="<?php the_permalink(); ?>">
                        <?php the_title(); ?>
                        </a></h3>
                    </div>
                  </div>
                  <!-- End Item -->

                  <?php $ctr++; 
            endwhile;  ?>
                </div>
                <!-- End Carousel Inner -->

                <div class="thumbs">
                  <div class="row">
                    <div class="col-md-2 active item" data-target="#myCarousel" data-slide-to="0"><a href="#"><img src="http://placehold.it/1200x440/999999/cccccc" class="img-responsive"></a></div>
                    <?php for($num = 1; $num < $count; $num++){ ?>
                    <div class="col-md-2 item" data-target="#myCarousel" data-slide-to="<?php echo $num; ?>"><a href="#"><img src="http://placehold.it/1200x440/999999/cccccc" class="img-responsive"></a></div>
                    <?php } ?>
                  </div>
                </div>
              </div>
              <!-- End Carousel -->
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-18 20:36:42

而不是:

代码语言:javascript
复制
<?php for($num = 1; $num < $count; $num++){ ?>
    <div class="col-md-2 item" data-target="#myCarousel" data-slide-to="<?php echo $num; ?>">
        <a href="#">
            <img src="http://placehold.it/1200x440/999999/cccccc" class="img-responsive">
        </a>
    </div>
<?php } ?>

试着使用:

代码语言:javascript
复制
<?php $counter2 = 0; ?>
<?php while ( $items->have_posts() ) : $items->the_post(); ?>
    <?php $counter2++; ?>
    <div class="col-md-2 item <?php echo $counter2 == 1 ? 'active' : ''; ?>" data-target="#myCarousel" data-slide-to="<?php echo $counter2; ?>">
        <a href="#">
            <?php
            the_post_thumbnail('thumbnail', array(
                'class' => 'img-responsive'
            ));
            ?>
        </a>
    </div>
<?php endwhile; ?>

这将用标记显示它,但使用缩略图图像而不是占位符。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25921738

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档