Last active
September 30, 2015 14:32
-
-
Save carlitoescobar/b20fbc10bb7b273059d1 to your computer and use it in GitHub Desktop.
Only return taxonomies that exist in current loop. Using it on another taxonomy terms archive page.
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 | |
while (have_posts()) : the_post(); | |
$taxonomy = 'your_taxonomy'; // change this to your taxonomy | |
//$terms = wp_get_post_terms( $post->ID, $taxonomy, array( "fields" => "ids" ) ); | |
$terms = wp_get_post_terms( $post->ID, $taxonomy, array( "fields" => "slugs" ) ); | |
if( $terms ) $all_terms = array_merge($all_terms, $terms); | |
endwhile; | |
if ($all_terms) : | |
$all_terms = array_unique($all_terms); | |
//$terms = trim( implode( ' ', (array) $all_terms ), ' ,' ); | |
echo '<ul>'; | |
//wp_list_categories( 'title_li=&taxonomy=' . $taxonomy . '&include=' . $terms ); | |
//echo $terms; | |
foreach ( $all_terms as $termname ) { | |
echo '<li>' . $termname . '</li>'; | |
} | |
echo '</ul>'; | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment