Created
November 11, 2016 23:30
-
-
Save Regis011/4fc5e54f2cda13cabff9dd4d5b93edf6 to your computer and use it in GitHub Desktop.
Wordpress Taxonomy Archive Template
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 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source:
get the terms
https://developer.wordpress.org/reference/functions/get_the_terms/
get the terms list
https://codex.wordpress.org/Function_Reference/get_the_term_list
get post term
https://codex.wordpress.org/Function_Reference/wp_get_post_terms
get taxonomy
https://codex.wordpress.org/Function_Reference/get_taxonomies