【发布时间】:2017-08-27 08:07:24
【问题描述】:
大家好,我正在我的 WordPress 项目中实现引导轮播。我正在使用复选框来列出我的类别,它看起来像这样:
我希望用户能够根据他们选择的类别更改我的轮播内容。
基本上我需要根据用户选择的复选框来更改我的查询。我的查询需要根据用户选择的类别进行更改,例如'category_name' => 'test1, test2'
这是我的代码:
<div class="col-md-7 col-md-offset-4 main-content">
<div class="checkbox">
<label class="checkbox-inline">
<input type="checkbox" name="allRadios" id="allRadios" value="all">
all
</label>
<label class="checkbox-inline">
<input type="checkbox" name="frontendRadios" id="frontendRadios" value="frontend" checked>
front end
</label>
<label class="checkbox-inline">
<input type="checkbox" name="wordpressRadios" id="wordpressRadios" value="wordpress" checked>
wordpress
</label>
<label class="checkbox-inline">
<input type="checkbox" name="designRadios" id="designRadios" value="design" checked>
design
</label>
<label class="checkbox-inline">
<input type="checkbox" name="seoRadios" id="seoRadios" value="seo" checked>
seo
</label>
</div>
</div>
<!-- Here starts carousel loop -->
<?php $carauselLoop = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => -1, 'category_name' => 'testing' ) ); ?>
<?php $i=1; ?>
<div class="col-md-4 our-work-info">
<div class="clients-num">
<h5 title="01">01</h5>
</div>
<span class="glyphicon glyphicon-link"></span>
<h3>Crossroads</h3>
<h4 class="sub-heading">front end / wordpress</h4>
</div>
<div class="col-md-7">
<div id="our-work-carousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php while ( $carauselLoop->have_posts() ) : $carauselLoop->the_post(); ?>
<div class="item <?php if ($i == 1) echo 'active'; ?>">
<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id() ); ?>" alt="<?php the_title(); ?>">
<div class="carousel-caption">
<a href="<?php the_permalink() ?>"><h3><?php the_title(); ?></h3></a>
</div>
</div>
<?php $i++; ?>
<?php endwhile; wp_reset_query(); ?>
</div>
<!-- Indicators -->
<ol class="carousel-indicators our-work-indicators">
<li data-target="#our-work-carousel" data-slide-to="0" class="active"></li>
<li data-target="#our-work-carousel" data-slide-to="1"></li>
<li data-target="#our-work-carousel" data-slide-to="2"></li>
</ol>
<!-- Controls -->
<a class="left carousel-control" href="#our-work-carousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#our-work-carousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
有没有办法实现这一点,我应该如何处理它?
【问题讨论】:
标签: php jquery wordpress twitter-bootstrap