你好,我一直在为我的足球博客开发一个特定的主题体育引导主题。我试着循环主题的滑块,但尽管我尽了全力,主题还是不断分散。我真的很想得到任何帮助,谢谢。下面是我一直在上工作的php代码
<div class="col-md-6">
<div class="feature_news_carousel">
<div id="featured-news-carousal" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php
$args = array(
'category_name' => 'latest',
'posts_per_page'=> 4
);
$uk_soccer = new WP_Query($args);
if ( $uk_soccer->have_posts() ) : while ( $uk_soccer->have_posts() ): $uk_soccer->the_post();
?>
<div class="item active feature_news_item">
<div class="item_wrapper">
<div class="item_img">
<img class="img-responsive" src="<?php the_post_thumbnail_url(); ?>" alt="<?php the_title(); ?>">
</div> <!--item_img-->
<div class="item_title_date">
<div class="news_item_title">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
</div>
<div class="item_meta"><?php echo get_the_date('M, j Y'); ?> at <?php the_time(); ?>,</a> by:<a href="#"><?php echo get_author_name(); ?></a></div>
</div> <!--item_title_date-->
</div> <!--item_wrapper-->
<div class="item_content"><?php echo excerpt(15); ?></div>
</div><!--feature_news_item-->
<?php
endwhile;
endif;
wp_reset_postdata();
?>
<!-- Left and right controls -->
<div class="control-wrapper">
<a class="left carousel-control" href="#featured-news-carousal" role="button" data-slide="prev">
<i class="fa fa-chevron-left" aria-hidden="true"></i>
</a>
<a class="right carousel-control" href="#featured-news-carousal" role="button" data-slide="next">
<i class="fa fa-chevron-right" aria-hidden="true"></i>
</a>
</div>
</div><!--carousel-inner-->
</div><!--carousel-->
</div><!--feature_news_carousel-->
</div><!--col-md-6-->
把这个代码放进去,这样你的滑块就可以工作了
<div class="col-md-6">
<div class="feature_news_carousel">
<div id="featured-news-carousal" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php
$args = array(
'category_name' => 'latest',
'posts_per_page'=> 4
);
$uk_soccer = new WP_Query($args);
if ( $uk_soccer->have_posts() ) :
$index = 0;
while ( $uk_soccer->have_posts() ): $uk_soccer->the_post();
?>
<div class="<?php echo ($index == 0) ? 'active' : ''; ?>feature_news_item">
<div class="item_wrapper">
<div class="item_img">
<img class="img-responsive" src="<?php the_post_thumbnail_url(); ?>" alt="<?php the_title(); ?>">
</div> <!--item_img-->
<div class="item_title_date">
<div class="news_item_title">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
</div>
<div class="item_meta"><?php echo get_the_date('M, j Y'); ?> at <?php the_time(); ?>,</a> by:<a href="#"><?php echo get_author_name(); ?></a></div>
</div> <!--item_title_date-->
</div> <!--item_wrapper-->
<div class="item_content"><?php echo excerpt(15); ?></div>
</div><!--feature_news_item-->
<?php
$index++;
endwhile;
endif;
wp_reset_postdata();
?>
<!-- Left and right controls -->
<div class="control-wrapper">
<a class="left carousel-control" href="#featured-news-carousal" role="button" data-slide="prev">
<i class="fa fa-chevron-left" aria-hidden="true"></i>
</a>
<a class="right carousel-control" href="#featured-news-carousal" role="button" data-slide="next">
<i class="fa fa-chevron-right" aria-hidden="true"></i>
</a>
</div>
</div><!--carousel-inner-->
</div><!--carousel-->
</div><!--feature_news_carousel-->
</div><!--col-md-6-->