false, 'show_select_a_category' => 1, 'show_all_categories' => 1, 'html_select_id' => '', 'html_select_class' =>'', 'html_select_name' => '', 'html_option_level_class' => 'level-' ); $r = wp_parse_args( $args, $defaults ); echo ''; echo_option_catagories_deep($r); echo ''; } function echo_option_catagories_deep ($args, $parent_id = 0, $level = 0) { global $wpdb; /* $args must be provided with all parameters. See echo_select_catagories() */ if ($level == 0) { if ($args['show_select_a_category']) echo ''; if ($args['show_all_categories']) echo ''; } $sql = "SELECT t.term_id, t.name FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'category' AND tt.parent = $parent_id"; $items = $wpdb->get_results ($sql); foreach ($items as $item) { $option = ''; echo $option; $list = echo_option_catagories_deep ($args, $item->term_id, $level+1); } //return $list; }