Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to get the term links for a specific post
<?php
$taxonomy = 'project_category';
$terms = wp_get_post_terms($post->ID, $taxonomy);
//print_rr($terms);
foreach ($terms as $term) {
$term_link = get_term_link( $term, $taxonomy );
if ( is_wp_error( $term_link ) )
echo $term_link->get_error_message();
if ( is_wp_error( $term_link ) ) {
continue;
} ?>
<li><a href="<?php echo esc_url( $term_link ); ?>"><?php echo $term->name; ?></a></li>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.