-
-
Save jhebb/4688574 to your computer and use it in GitHub Desktop.
Show custom taxonomy with custom markup
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 | |
$query = new WP_Query(array('post_type' => 'custom-post-type')); | |
while ($query->have_posts()) : $query->the_post(); | |
$terms = get_the_terms( $post->id, 'custom-taxonomy' ); // registered custom taxonomy in custom post type | |
if( $terms && ! is_wp_error( terms ) ) { | |
foreach( $terms as $term ) { | |
echo '<a class="term-' . $term->slug . '" href="' . get_term_link($term) . '" title="' . $term->name .'">' . $term->name .'</a>'; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment