2 added 18 characters in body
source | link

Just a quick thoughtEDIT: I had suggested adding endforeach;, but perhaps you needI just relooked at the code example in the codex and they don't use it, so it doesn't look necessary.

Another suggestion would be to closefollow the eachexample for get_term_link() without using the nested foreach() with and endforeach; ?to see if you can get it to produce the desired "Top Layer Term" results.

One benefit of their code example is that seems to continue through an error:

  $terms = $taxonomyNameget_terms( ='team_categories' "team_categories";);

echo '<ul>';

foreach ( $terms //Thisas gets$term top) layer{

 terms only.  This// isSanitize donethe byterm, settingsince parentwe towill 0.be displaying it.
    $parent_terms$term = get_terms($taxonomyName, arraysanitize_term('parent' => 0, 'orderby' => 'slug'$term,   'hide_empty' =>'team_categories' false));   
    echo '<ul>';
    foreach$term_link = get_term_link($parent_terms as$term, $pterm)'team_categories' {);
     
    //Get theIf Childthere terms
was an error, continue to the next term.
 $terms = get_terms($taxonomyName, array('parent'if =>( $pterm->term_id,is_wp_error( 'orderby'$term_link =>) ) {
 'slug', 'hide_empty' => false));
    continue;
    foreach}

 ($terms as $term) {
// We successfully got a link. Print it out.
    echo '<li><a href="' . get_term_linkesc_url( $term->name, $taxonomyName$term_link ) . '">' . $term->name . '</a></li>';  
        }
        endforeach; 
    }
    endforeach;
    echo '</ul>';

Another suggestion would be to follow the example for get_term_link() without using the nested foreach() to see if you can get it to produce the desired "Top Layer Term" results. If it doesthat works, then add the extra complexity using the example style of code formatting.

Just a quick thought, but perhaps you need to close the each foreach() with and endforeach; ?

    $taxonomyName = "team_categories";
    //This gets top layer terms only.  This is done by setting parent to 0.  
    $parent_terms = get_terms($taxonomyName, array('parent' => 0, 'orderby' => 'slug',   'hide_empty' => false));   
    echo '<ul>';
    foreach ($parent_terms as $pterm) {
        //Get the Child terms
        $terms = get_terms($taxonomyName, array('parent' => $pterm->term_id, 'orderby' =>   'slug', 'hide_empty' => false));
        foreach ($terms as $term) {
            echo '<li><a href="' . get_term_link( $term->name, $taxonomyName ) . '">' . $term->name . '</a></li>';  
        }
        endforeach; 
    }
    endforeach;
    echo '</ul>';

Another suggestion would be to follow the example for get_term_link() without using the nested foreach() to see if you can get it to produce the desired "Top Layer Term" results. If it does, then add the extra complexity using the example style of code formatting.

EDIT: I had suggested adding endforeach;, but I just relooked at the code example in the codex and they don't use it, so it doesn't look necessary.

Another suggestion would be to follow the example for get_term_link() without using the nested foreach() to see if you can get it to produce the desired "Top Layer Term" results.

One benefit of their code example is that seems to continue through an error:

$terms = get_terms( 'team_categories' );

echo '<ul>';

foreach ( $terms as $term ) {

    // Sanitize the term, since we will be displaying it.
    $term = sanitize_term( $term, 'team_categories' );

    $term_link = get_term_link( $term, 'team_categories' );
 
    // If there was an error, continue to the next term.
    if ( is_wp_error( $term_link ) ) {
        continue;
    }

    // We successfully got a link. Print it out.
    echo '<li><a href="' . esc_url( $term_link ) . '">' . $term->name . '</a></li>';
}

echo '</ul>';

If that works, then add the extra complexity using the example style of code formatting.

1
source | link

Just a quick thought, but perhaps you need to close the each foreach() with and endforeach; ?

    $taxonomyName = "team_categories";
    //This gets top layer terms only.  This is done by setting parent to 0.  
    $parent_terms = get_terms($taxonomyName, array('parent' => 0, 'orderby' => 'slug',   'hide_empty' => false));   
    echo '<ul>';
    foreach ($parent_terms as $pterm) {
        //Get the Child terms
        $terms = get_terms($taxonomyName, array('parent' => $pterm->term_id, 'orderby' =>   'slug', 'hide_empty' => false));
        foreach ($terms as $term) {
            echo '<li><a href="' . get_term_link( $term->name, $taxonomyName ) . '">' . $term->name . '</a></li>';  
        }
        endforeach; 
    }
    endforeach;
    echo '</ul>';

Another suggestion would be to follow the example for get_term_link() without using the nested foreach() to see if you can get it to produce the desired "Top Layer Term" results. If it does, then add the extra complexity using the example style of code formatting.