Site icon Hip-Hop Website Design and Development

Custom taxonomy: on the taxonomy term page show other taxonomy terms

ok, i have a custom post type LAW and two taxonomy LAW TYPE and EDITION
I create a page taxonomy-law_type.php for display child terms LAW TYPE

<ul class="wpb_page_list">
<?php 
    $term = get_queried_object();

$children = get_terms( $term->taxonomy, array(
    'parent'    => $term->term_id,
    'hide_empty' => false
) );

if ( $children ) { 
    foreach( $children as $subcat )
    {
        echo '<li style="display:flex"><a href="' . esc_url(get_term_link($subcat, $subcat->taxonomy)) . '">' . // wrapped
          $subcat->name . ' (' . $subcat->count . ')' . '</a></li>';
    }
}
?></ul>

and page taxonomy-law_type-term.php

<!-- Content -->
    <div id="content" class="content" role="main">
        <?php
        the_archive_description( '<div class="taxonomy-description">', '</div>' );

        if ( have_posts() ) {
            the7_archive_loop();
    } else {
            get_template_part( 'no-results', 'search' );
        }
    ?>
        <ul class="wpb_page_list">
<?php 
    $term = get_queried_object();

$children = get_terms( $term->taxonomy, array(
    'parent'    => $term->term_id,
    'hide_empty' => false
) );

if ( $children ) { 
    foreach( $children as $subcat )
    {
        echo '<li style="display:flex"><a href="' . esc_url(get_term_link($subcat, $subcat->taxonomy)) . '">' . // wrapped
          $subcat->name . ' (' . $subcat->count . ')' . '</a></li>';
    }
}
?></ul>

</div><!-- #content -->

But, if the post contains a term from taxonomy LAW TYPE and term from taxonomy EDITION, then on the page taxonomy-law_type-term.php, need to show the list terms of taxonomy EDITION in which there are posts for the current term taxonomy LAW TYPE. If note, show posts for current term taxonomy LAW TYPE

Help please 🙄