get_term_children specific no id
hi everyone from the codex I found what I needed that is to show the sub-taxonomies by specifying the id of the sub-taxonomy and the macro taxonomy
get_term_children( int $term_id, string $taxonomy )
with the example shown
?php
$term_id = 10;
$taxonomy_name = 'products';
$termchildren = get_term_children( $term_id, $taxonomy_name );
echo 'ul';
foreach ( $termchildren as $child ) {
$term = get_term_by( 'id', $child, $taxonomy_name );
echo 'lia href="' . get_term_link( $child, $taxonomy_name ) . '"' . $term-name . '/a/li';
}
echo '/ul';
?
ok and this works perfectly, i was wondering if there was another possibility instead of specifying the id of the sub-taxonomy which is not exactly the best it is possible specifying by writing the name, how could it be done?
to have a typical result
?php
$term_id = 'telephone';
$taxonomy_name = 'products';
$termchildren = get_term_children( $term_id, $taxonomy_name );
echo 'ul';
foreach ( $termchildren as $child ) {
$term = get_term_by( 'id', $child, $taxonomy_name );
echo 'lia href="' . get_term_link( $child, $taxonomy_name ) . '"' . $term-name . '/a/li';
}
echo '/ul';
?
I wrote macro and micro only for understanding of question, however the context is "archive" taxonomy or the taxonomy-xxx.php, the problem is that I am in this situation(example) category-> training-> basketball, according to the archive page taxonomy basketball, I would like to let all the training children out and I would not do it with the id
Topic get-children taxonomy custom-taxonomy Wordpress
Category Web