Created
February 23, 2015 20:44
-
-
Save anonymous/582f0c45e35ae8c38561 to your computer and use it in GitHub Desktop.
How to get the term links for a specific post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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