So Ive got this function here that creates a drop-down menu from only the child categories, it works great.
The problem is that I need to get the parent categories name and assign it as the value of the option class for the child category menus. I can't seem to get it to work, all I get is either '/' or '/child_Category_name/'
Thanks!
function child_dropdown($dropID, $taxonomy, $exclude) {
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 1,
'exclude' => $exclude,
'taxonomy' => $taxonomy,
'pad_counts' => false );
$categories = get_categories( $args );
$menu = '<select name="'.$dropID.'" id="'.$dropID.'" class="postform">';
$menu .='<option value="">--</option>';
foreach($categories as $category)
{
if($category->parent != 0 ) {
$menu .= '<option class="'.get_category_parents().'" value="'.$category->name.'">'.$category->name.'</option>';
}
}
$menu .= '</select>';
echo $menu;
}
get_category_parents( $category->id )
, which returns a string of the parents, delimited by/
by default.