I need to create an Array that contains all of the children slugs of a specific parent category ID.
Let's say I have the following parent category and its children categories:
- Food
- pizza
- bread
- banana
- ice cream
I need a code/function to use inside functions.php
that returns the slugs of all of the children's slug of a specific parent category like this:
function-get-child-slug( $parentID='1');
It returns this:
array('pizza','bread','banana','ice-cream')
I've tried some variants of this but it didn't work:
$var = wp_list_categories( array(
'child_of' => 1,
'echo' =>false
) );
$array = array(strip_tags($var));
How can I achieve this?