我有以下代码来列出所有术语,但我需要一个代码,其中我只能列出“父术语”,因为它们也都有子术语
<?php
// output quick links list of countries
$terms = get_terms(\'apptypes\');
if (count($terms)) {
echo "<h3>Quick links</h3>";
echo "<p style=\\"text-align:center;\\">";
}
$i=0; // counter for printing separator bars
foreach ($terms as $term) {
$wpq = array (\'taxonomy\'=>\'apptypes\',\'term\'=>$term->slug);
$query = new WP_Query ($wpq);
$article_count = $query->post_count;
echo "<a href=\\"#".$term->slug."\\">".$term->name."</a>";
// output separator bar if not last item in list
if ( $i < count($terms)-1 ) {
echo " | " ;
}
$i++;
}
if (count($terms)) {
echo "</p>";
}
?>