Skip to content

Instantly share code, notes, and snippets.

@Regis011
Created November 11, 2016 23:30
Show Gist options
  • Save Regis011/4fc5e54f2cda13cabff9dd4d5b93edf6 to your computer and use it in GitHub Desktop.
Save Regis011/4fc5e54f2cda13cabff9dd4d5b93edf6 to your computer and use it in GitHub Desktop.
Wordpress Taxonomy Archive Template
<?php the_terms($post->ID, 'group') ?>
<?php echo get_the_term_list( $post->ID, 'styles', '<ul class="styles"><li>', ',</li><li>', '</li></ul>' ); ?>
<?php $terms = wp_get_post_terms( $post->ID, 'fragorna', array('fields' => 'all') );
print_r($terms[0]->description);
?>
// custom - get taxomnomy
<?php if ($taxonomies): ?>
<?php foreach ($taxonomies as $taxonomy ) { ?>
<?php $terms = get_terms($taxonomy, array('hide_empty' => false)); ?>
<?php foreach ( $terms as $term) { ?>
<?php # print_r($term); ?>
<li>
<a href="/fragorna/<?php echo $term->slug; ?>/">
<?php echo $term->name; ?>
</a>
<p>
<?php echo $term->description; ?>
</p>
</li>
<?php } ?>
<?php } ?>
<?php endif; ?>
//Get term slug of current post
$terms = get_the_terms( $post->ID, 'your-taxonomy' );
if ( !empty( $terms ) ){
// get the first term
$term = array_shift( $terms );
echo $term->slug;
}