问题描述
我有一些分类法,其中之一是属性类型,在分类法下拉列表中,分类法按层次结构显示。但是如何显示带有复选框的分层下拉列表?。如何更改此代码? Here,I wanna display it in front end
非常感谢任何帮助!
<?PHP
/** The taxonomy we want to parse */
$taxonomy = "property_type_taxonomy";
/** Get all taxonomy terms */
$terms = get_terms($taxonomy,array(
"orderby" => "count","hide_empty" => false
)
);
/** Get terms that have children */
$hierarchy = _get_term_hierarchy($taxonomy);
?>
<select name="terms" id="terms" multiple>
<?PHP
/** Loop through every term */
foreach($terms as $term) {
/** Skip term if it has children */
if($term->parent) {
continue;
}
echo '<option value="' . $term->name . '">' . $term->name . '</option>';
/** If the term has children... */
if($hierarchy[$term->term_id]) {
/** ...display them */
foreach($hierarchy[$term->term_id] as $child) {
/** Get the term object by its ID */
$child = get_term($child,"property_type_taxonomy");
echo '<option value="' . $term->name . '"> - ' . $child->name . '</option>';
}
}
}
?>
</select>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)