<div class="small-12 columns">
<ul class="category-filters">
<?php
$args = array(
'parent' => 0,
'exclude' => '1, 9'
);
$cats = get_categories($args);
foreach($cats as $cat) {
$output =
'<li>
<input class="checkbox" type="checkbox" value="' . $cat->cat_name . '">'
. $cat->cat_name .
'</li>';
echo $output;
}
?>
</ul>
<h4>Meet our Coaches</h4>
<?php
$wpb_all_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>-1));
if ( $wpb_all_query->have_posts() ) : ?>
<?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
<div class="callout horizontal word-wrap"
data-category="
<?php
$cats=get_the_category();
echo $cats[0]->cat_name;
?>">
<?php the_post_thumbnail() ?>
<h5><?php the_title(); ?></h5>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
我有上面的php。它会创建一个复选框列表,然后在循环浏览wordpress中所有类别的标注上创建一个列表。
我想知道如何修改此代码,以便它永远不会为类别&#39;指导创建和复选框或标注。
除了这个问题之外,很高兴知道是否有更好的方法通过wordpress提供的我错过的东西来获得我想要的结果。