Skip to content

Instantly share code, notes, and snippets.

@jhebb
Forked from johnbhartley/Custom Tax
Last active December 12, 2015 01:08
Show Gist options
  • Save jhebb/4688574 to your computer and use it in GitHub Desktop.
Save jhebb/4688574 to your computer and use it in GitHub Desktop.
Show custom taxonomy with custom markup
<?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