Getting an array of plain IDs of childterms

14 Views Asked by At

I am looking for a solution to get just the IDs of all childterms related to a parent in a custom taxonomy. I need them to put them into $args for a query.

What I have so far is:

$children = get_term_children($term->term_id, 'Taxonomy_name'); print_r( $children );

What I get is: Array ( [0] => 34 [1] => 41 [2] => 2124 [3] => 2126 [4] => 2363 [5] => 2606 [6] => 20014 )

What i need in the end is: $variable = '34, 41, 2124, 2126, 2363, 2606, 20014';

So i can use it for the $args in the query:

'terms' => $variable,

I spent hours on searching. Is there a simple solution ?

0

There are 0 best solutions below