如果父母或孩子,我有一个打印所有分类的代码
<form class="navbar-form navbar-right m-t m-l-n-xs" role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<div class="form-group dropdown" id="ajax-search">
<input type="hidden" name="">
<div class="input-group">
<select name="download_category">
<option value="" style="display:none">My Cats</option>
<?php
$terms = get_terms([
'taxonomy' => 'download_category',
'hide_empty' => false,
'parent' => false,
]);
echo $_GET['download_category'];
foreach($terms as $ter){
?>
<option value="<?php echo $ter->slug;?>"<?php
if($_GET['download_category'] == $ter->slug){
echo "selected=\"selected\"";
}
?>><?php echo $ter->name;?></option>
<?php
}
?>
</select>
</div>
<div class="input-group">
<input type="submit" value="Search">
</div>
</div>
</form>
我需要对父级和子级中的类别进行排序,例如按父级和子 级排序类别