您只需设置parent
的参数get_categories()
(或者更好,get_terms()
到的IDthe-building-code
学期如果您不知道ID,则需要首先检索该ID:
<form class="js-filter-form">
<select name="categories" id="categories">
<?php
$parent = get_term_by( \'slug\', \'the-building-code\', \'podcast_category\' );
$cat_args = array(
\'taxonomy\' => \'podcast_category\',
\'parent\' => $parent->term_id,
);
$categories = get_categories($cat_args); ?>
<option value="">All</option>
<?php
foreach($categories as $cat) : ?>
<option class="js-filter-item" value="<?= $cat->term_id; ?>">
<?= $cat->name; ?>
</option>
<?php endforeach; ?>
</select>
</form>
还请注意,没有
post_type
的参数
get_categories()
或
get_terms()
, 所以我把它拿走了。