I’m trying to get anoter level subcategory to show in my select option.
I’ve managed to get one… how can i get the other?
<?php
$taxonomies = array(CUSTOM_CAT_TYPE);
$args = array('orderby' => 'count', 'hide_empty' => 0);
$myterms = get_terms($taxonomies, $args);
$output = "<select class="select" name='select_cat' title="Select Category">";
$output .= "<option value=''>Selecteer Rubriek</option>";
foreach ($myterms as $cate)
{
if($cate->parent == 0)
{
$catename = "";
$catename = $cate->name;
$output .='<option disabled="disabled" value="'.$cate->term_id.'">'.$catename. '</option>';
foreach ($myterms as $subcate)
{
if($subcate->parent == $cate->term_id)
{
$catename = "";
$catename = $subcate->name;
$output .='<option value="'.$subcate->term_id.'">'.' '.$catename.'</option>';
foreach ($subcate as $subsubcate)
{
if($subsubcate->parent == $cate->term_id)
{
$catename = "";
$catename = $subsubcate->name;
$output .='<option value="'.$subsubcate->term_id.'">'.' '.$catename.'</option>';
}
}
}
}
}
}
$output .="</select>";
echo $output;
?>
Any ideas?! Or perhaps a better way to get where I want to be! 🙂
Found the solution! 🙂
Thanks for helping out!