0
需要帮助:我必须只显示自定义分类标准WordPress的特定父项的子项,在我的情况下:分类标准名称:“region”,与此有关:父母条款及其子女: 欧洲: - 葡萄牙; - 德国; - 英格兰;想要只显示自定义分类标准的特定父项的子项WordPress
亚洲: - China;日本; - 日本;
因此,例如我需要在列表中只显示欧洲的儿童,我该如何做到这一点?我试了很多方法,只能显示所有父母的所有孩子:
<?php
$taxonomyName = "region";
//This gets top layer terms only. This is done by setting parent to 0.
$parent_terms = get_terms($taxonomyName, array('parent' => 0, 'orderby' => 'slug', 'hide_empty' => false));
echo '<ul>';
foreach ($parent_terms as $pterm) {
//Get the Child terms
$terms = get_terms($taxonomyName, array('parent' => $pterm->term_id, 'orderby' => 'slug', 'hide_empty' => false));
foreach ($terms as $term) {
echo '<li><a href="' . get_term_link($term) . '">' . $term->name . '</a></li>';
}
}
echo '</ul>';
?>
但我只需要显示一个特定的父母。谢谢你的帮助