function michsci_get_terms_dropdown($cat_id)
{
$taxonomyName = MICHSCI_CATEGORY_NAME;
-
if($cat_id){
$main = get_term($cat_id, MICHSCI_CATEGORY_NAME);
$cats_child = get_term_children($cat_id, $taxonomyName);
} else {
$parent_terms = get_terms($taxonomyName, array('parent' => 0, 'orderby' => 'name', 'hide_empty' => false));
+ $terms = get_terms($taxonomyName, array('orderby' => 'name', 'hide_empty' => false));
+
$output ="<select id='categoryDropdown' name=\"" . MICHSCI_CATEGORY_NAME . "\"><option value=\"\">Select " . MICHSCI_CATEGORY_SINGLE . "</option>";
// get parent categories
foreach ($parent_terms as $parent){
// get children of each category
- $child_terms = get_terms($taxonomyName, array('child_of' => $parent->term_id, 'orderby' => 'name', 'hide_empty' => false));
+ $child_terms = get_terms($taxonomyName, array('parent'=> $parent->term_id, 'child_of' => $parent->term_id, 'orderby' => 'name', 'hide_empty' => false));
$output .= '<option value="' . $parent->term_id . '"';
if ($_REQUEST[MICHSCI_CATEGORY_NAME] == $parent->term_id) {
$output .= ' selected';
}
$output .= '>' . $parent->name . '</option>';
foreach($child_terms as $child){
- $grandchildren = get_terms($taxonomyName, array('child_of' => $child->term_id, 'orderby' => 'name', 'hide_empty' => false));
+ $grandchildren = get_terms($taxonomyName, array( 'child_of' => $child->term_id, 'orderby' => 'name', 'hide_empty' => false));
$output .= '<option value="' . $child->term_id . '"';
if ($_REQUEST[MICHSCI_CATEGORY_NAME] == $child->term_id) {
$output .= ' selected';
}
$output .= '>' . "   " . $child->name . '</option>';
- }
+ foreach($grandchildren as $gchild){
+ $output .= '<option value="' . $gchild->term_id . '"';
+ if ($_REQUEST[MICHSCI_CATEGORY_NAME] == $gchild->term_id) {
+ $output .= ' selected';
+ }
+ $output .= '>' . "      " . $gchild->name . '</option>';
+ }
}
+ }
+
+
$output .="</select>"; }
return $output;
}