custom_taxonomy drop down works, but is not heirachical
-
I have created a drop down of my custom taxonomies using the code below:
function get_terms_dropdown($taxonomies, $args){ $myterms = get_terms($taxonomies, $args); $output ="<select name='{TERM}'>"; foreach($myterms as $term){ $root_url = get_bloginfo('url'); $term_taxonomy=$term->taxonomy; $term_slug=$term->slug; $term_name =$term->name; $link = $term_slug; $output .="<option value='".$link."'>".$term_name." (".$term->count.") </option>"; } $output .="</select>"; return $output; }
I then place this in my template:
<form action="<?php bloginfo('url'); ?>" method="get"> <div> <?php $taxonomies = array('{TERM}'); $args = array('orderby'=>'name','hierarchical'=>true); $select = get_terms_dropdown($taxonomies, $args); $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select); echo $select; ?> <noscript><div><input type="submit" /></div></noscript> </div></form>
It outputs a dropdown populated with the terms but the terms are list totally flat. They are not hierarchical, but
'hierarchical'=>true
has been set to true.Does anyone have any ideas, why the
'hierarchical'=>true
is not getting read?Thank you!
- The topic ‘custom_taxonomy drop down works, but is not heirachical’ is closed to new replies.