wordpress get taxonomy of a displayed item -
i`m writing wordpress theme. need display parents of current item belongs taxonomy. first thing need taxonomy of item displayed. here tried do:
$id = get_the_id(); $taxonomy = get_term_by('id', $id)['taxonomy']; echo 'current taxonomy ' . $taxonomy; $terms = get_the_terms( $id, $taxonomy); for($i = count( $terms ) - 1; $i >= 0; $i--){ echo '><a href="' . get_term_link( $terms[$i] ) . '">' . $terms[$i]->name . '</a>'; }
the first problem i`ve faced $taxonomy = "". please me.
you can terms wp_get_post_terms more information
click here
Comments
Post a Comment