如何解决如何使用分层术语在多选复选框前端显示分类法
我有一些分类法,其中之一是属性类型,在分类法下拉列表中,分类法按层次结构显示。但是如何显示带有复选框的分层下拉列表?。如何更改此代码? 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 举报,一经查实,本站将立刻删除。