$terms = get_terms([
'taxonomy' => array('Movies, Musics, Books, Games'),
'parent' => 0,
'depth'=> 2,
'hide_empty' => false,
]);
$sorted_terms = [];
if ( $terms ) {
foreach ( $terms as $term ) {
$sorted_term = [
'WP_Term' => $term, // the global term
'icon' => get_field( 'logo', $term->taxonomy . '_' . $term->term_id ),
'srating' => get_field( 'rating', $term->taxonomy . '_' . $term->term_id ),
'carrentActiveClass' => '',
'count' => (int) wpse340250_term_count( $term, 'sikayet' ),
// everything you will need later here
];
///// and my code continue
in the above code I can get terms of different taxonomies. But I am trying to get children of taxonomy terms. Can any one help me please
'parent' => 0,
'depth'=> 2,
did not work
$terms = get_terms([
'taxonomy' => array('Movies, Musics, Books, Games'),
'parent' => 0,
'depth'=> 2,
'hide_empty' => false,
]);
$sorted_terms = [];
if ( $terms ) {
foreach ( $terms as $term ) {
$sorted_term = [
'WP_Term' => $term, // the global term
'icon' => get_field( 'logo', $term->taxonomy . '_' . $term->term_id ),
'srating' => get_field( 'rating', $term->taxonomy . '_' . $term->term_id ),
'carrentActiveClass' => '',
'count' => (int) wpse340250_term_count( $term, 'sikayet' ),
// everything you will need later here
];
///// and my code continue
in the above code I can get terms of different taxonomies. But I am trying to get children of taxonomy terms. Can any one help me please
'parent' => 0,
'depth'=> 2,
did not work
Share Improve this question edited Jan 22, 2021 at 16:24 Gidromasservis QSC asked Jan 22, 2021 at 16:18 Gidromasservis QSCGidromasservis QSC 331 silver badge10 bronze badges 3 |1 Answer
Reset to default 0not actually sure what you are trying to achieve with the code. I would write something like this to get the child terms
$terms = get_terms([
'taxonomy' => array('Movies, Musics, Books, Games'),
'parent' => 0,
'hide_empty' => false,
]);
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
foreach ($terms as $term) {
$child_term = get_term_children( $term->term_id, $term->taxonomy )
//your code here
}
}
'parent' => 0
, you are querying for the top-level taxonomies. – Sharif Mohammad Eunus Commented Jan 22, 2021 at 16:32