List custom taxonomy with children
-
I’m trying to create a list of links for a custom taxonomy along with the children of the terms. i.e:
<ul> <li><a href="/telephony">Telephony</a> <ul> <li><a href="/blackberry">BlackBerry</a></li> <li><a href="/fixed-ip">Fixed IP</a></li> </ul> </li> <li><a href="/email">Email</a> <ul> <li><a href="/fax">Fax</a></li> <li><a href="/text">Text</a></li> <li><a href="/nhs-email">NHS Email</a></li> </ul> </li> </ul>
So far I’ve got:
<?php $termID = 451; $taxonomyName = "service_line_category"; $termchildren = get_term_children( $termID, $taxonomyName ); echo '<ul>'; foreach ($termchildren as $child) { $term = get_term_by( 'id', $child, $taxonomyName ); echo '<li><a href="' . get_term_link( $term->name, $taxonomyName ) . '">' . $term->name . '</a></li>'; } echo '</ul>'; ?>
However this only grabs the children of ‘$termID = 451;’ but I’m not sure how to modify this to get the parents and the children for all of the terms within ‘service_line_category’ in a list.
Any ideas? I’m not really sure where to go with this.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘List custom taxonomy with children’ is closed to new replies.