I just spent more time that I’d like to admit trying to figure this out for a custom theme I’m working on. At least part of it ended up being a theme conflict. Either way, I am storing this handy snippet right here for safe keeping.
This will allow you to output term (category) links on individual posts within the WP Query Loop.
| <?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 } ?> |