所以我有以下代码,但是我不确定如何仅在单击时显示一个类别。默认情况下,它应该显示所有FAQ,但是当单击第二个项目时,它应该仅显示具有“会员资格”分类法的帖子。
<div class="main-faq-div">
<div class="categories">
<div class="sidebar active" id="4" onclick="showQuestions(this)">
All <i class="fa fa-chevron-right" aria-hidden="true"></i></div>
<div class="sidebar" id="3" onclick="showQuestions(this)">
Membership <i class="fa fa-chevron-right" aria-hidden="true"></i></div>
<div class="sidebar" id="5" onclick="showQuestions(this)">
Wills & Estates <i class="fa fa-chevron-right" aria-hidden="true"></i></div>
</div>
<div class="faq-box">
<?php $args = array( 'post_type' => 'faq', 'posts_per_page' => 40 , 'paged' => 1,);
$loop = new WP_Query( $args );
$counter = 1;
while ( $loop->have_posts() ) : $loop->the_post();
$title = get_the_title();
$content = get_the_content();
echo '<div class="tab blue"><input id="inputnumber' . $counter . '" type="checkbox" name="group1" class="trigger"><label for="inputnumber' . $counter . '">' . $title . '</label><span class="content">' . $content . '</span></div>';
$counter++;
endwhile;
?>
</div>