Last active
August 29, 2015 14:06
-
-
Save croosen/f8ffcf8dfc427492f827 to your computer and use it in GitHub Desktop.
WordPress - Show categories that belong to the current custom post
This file contains hidden or 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 = 'foo_cat'; // Your category | |
$terms = get_the_terms($post->ID, $taxonomy ); // Get data for post ID | |
if ( $terms && !is_wp_error( $terms ) ) : | |
?> | |
<?php foreach ( $terms as $term ) { ?> | |
<li><a href="<?php echo get_term_link($term->slug, $taxonomy); ?>"><?php echo $term->name; ?></a></li> | |
<?php } ?> | |
<?php endif;?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment