Displaying Categories and Sub Categories

I know this has been asked and answered before but the solutions are not working for my so I was wondering if something has changed or if I am doing something wrong. Want to display my Categories, Child Cats, Grand Child-Cats. This is my code:

function list_areas () {
$provincearg = array(
‘taxonomy’ => ‘area’,
‘hide_empty’ => false,
‘parent’=> 0,
);
$provinces = get_terms ($provincearg);
foreach ($provinces as $province) {
echo ‘<h2>’ .$province -> name. ‘</h2>’;

$municipalarg = array (
‘taxonomy’ => ‘area’,
‘hide_empty’ => false,
‘parent’=> $province -> term_id,
);
$municipalities = get_terms ($municipalarg);

echo ‘<ul>’;
foreach ($municipalities as $municipality) {
echo ‘<li>’ .$municipality -> name. ‘</li>’;
}
echo ‘<ul>’;
}
}

It outputs the Category but not the sub categories. I even went as far as puting in the ‘parent’ id, when I do this nothing gets displayed.

Any help will be appreciated.

Read more here:: Displaying Categories and Sub Categories

Leave a Reply

Your email address will not be published. Required fields are marked *