我希望有人可以帮助我,一直在网上寻找答案。我在本地主机中使用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 ?>
非常感谢您的帮助!谢谢