我希望有人可以帮助我,一直在网上寻找答案。 我在localhost中使用http://320press.com/wpbs/作为我的wordpress,但似乎旋转木马不能正常工作。
我需要提问,但重要的部分是第一个问题。
如何让旋转木马调用特定类别,而不是在我的wordpress中显示所有帖子
您需要点击箭头以使图片幻灯片正常工作,有没有办法将其设置为自动滑动?
<?php
$use_carousel = of_get_option('showhidden_slideroptions');
if ($use_carousel) {
?>
<div id="myCarousel" class="carousel slide">
<!-- Carousel items -->
<div class="carousel-inner">
<?php
global $post;
$tmp_post = $post;
$show_posts = of_get_option('slider_options');
$args = array( 'numberposts' => $show_posts ); // set this to how many posts you want in the carousel
$myposts = get_posts( $args );
$post_num = 0;
foreach( $myposts as $post ) : setup_postdata($post);
$post_num++;
$post_thumbnail_id = get_post_thumbnail_id();
$featured_src = wp_get_attachment_image_src( $post_thumbnail_id, 'wpbs-featured-carousel' );
?>
<div class="<?php if($post_num == 1){ echo 'active'; } ?> item">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( 'wpbs-featured-carousel' ); ?></a>
<div class="carousel-caption">
<h4><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4>
<p>
<?php
$excerpt_length = 100; // length of excerpt to show (in characters)
$the_excerpt = get_the_excerpt();
if($the_excerpt != ""){
$the_excerpt = substr( $the_excerpt, 0, $excerpt_length );
echo $the_excerpt . '... ';
?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>" class="btn btn-primary">Read more ›</a>
<?php } ?>
</p>
</div>
</div>
<?php endforeach; ?>
<?php $post = $tmp_post; ?>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
</div>
<?php } // ends the if use carousel statement ?>
非常感谢您的帮助!感谢
答案 0 :(得分:2)
试试这个。
在这里,您使用不在ID中的类来调用carousel初始化:
$(".class").carousel( { autoSlide: true } );
2.您需要单击箭头以使图像幻灯片正常工作,有没有办法将其设置为自动滑动? 我认为旋转木马为autoslide提供了如下参数:
$("div").carousel( { autoSlide: true } );
参赛网站:http://www.thomaslanciaux.pro/jquery/jquery_carousel.htm#autoslide