0
    $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

3
  • By setting 'parent' => 0, you are querying for the top-level taxonomies. Jan 22, 2021 at 16:32
  • when i change 0 to 1 , it doesnt show anything Jan 22, 2021 at 16:36
  • wooow I uderstant now, 'parent' => parent ID . thank you vey much Sharif Mohammad Eunus Jan 22, 2021 at 16:38

1 Answer 1

0

not 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
    }

}
10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.