I'm trying to output links to custom taxonomy assigned to a single post on a single post page. I've tried other thing but get errors. This is the closest I can get. It just needs to find the terms for the current post instead of outputting all terms of a taxonomy.
<?php
$term_id = 6;
$taxonomy_name = 'categories';
$termchildren = get_term_children( $term_id, $taxonomy_name );
foreach ( $termchildren as $child ) {
$term = get_term_by( 'id', $child, $taxonomy_name );
echo '<a href="' . get_term_link( $child, $taxonomy_name ) . '">' . $term->name . '</a> ';
}
?>
@Howdy_McGee I tried the following code, where 'adoption-status' is a term for the custom taxonomy 'categories'. I'm looking for children of 'adoption-status'. It doesn't output anything. No errors either.
<?php get_the_terms( $post->ID, 'adoption-status' ); ?>
The following code almost works but displays all 'categories' of the current post, not just those of the term (or sub-category) 'adoption-status'
<?php echo get_the_term_list( $post->ID, 'categories', '', '', '' );?>
get_the_terms
is usually the best bet for what you need.