Hi im wondering is there a way to include a variable in the child_of parameter rather than an integer.
Im trying to retrieve the child categories based on the current category im on, but because there are 32 categories, it seems I have to write out 32 elseifs which seems wrong.
$current_cat = get_query_var('cat');
$category = get_category($current_cat);
if ( $category->parent == '16' {
$cats=get_categories('child_of=16');
}
But I dont want to have to repeat this over and over,
Id rather do something like…
$current_cat = get_query_var('cat');
$category = get_category($current_cat);
$cat_parent = $category->parent;
$cats = get_categories('child_of=$cat_parent);
Is it this possible? (ps im still learning so I may have missed something simple)
Im not sure if this is what you are looking for: