Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to break down the custom taxonomies into a list to filter posts. such as

Front

  • small
  • medium
  • large

Middle

  • small
  • medium
  • large

Back

  • small
  • medium
  • large

no I can list each terms ok, but I need to nest it depending on if its Middle>medium etc this is the code I'm using but it only shows the first posts tax because of the id. how can i make it do this for all the post on the current page? thanks so much in advance.

$taxonomy = 'position';
$terms = get_the_terms( $post->ID , $taxonomy );
if ( !empty( $terms ) ) {
  echo '<ul>';
  foreach ( $terms as $term ) {
  $link = get_term_link( $term, $taxonomy );
  if ( !is_wp_error( $link ) )
    echo '<li class="' . $term->slug. '"><a href="' . $link . '" rel="tag">' . $term->name . '</a></li>';
 checkSizes();
  }
  echo '</ul>';
  }
}

// list all size terms 
function checkSizes(){
// check for positon terms
$size_tax = 'pa_size';

$size_terms = get_the_terms( $post->ID , $size_tax );
if ( !empty( $size_terms ) ){ 
 echo '<ul>';
 foreach ( $size_terms as $size_term ) {
 $size_link = get_term_link( $size_term, $size_tax );
 if ( !is_wp_error( $size_link ) )
  echo '<li class="' . $size_term->slug. '"><a href="' . $size_link . '" rel="tag">' .     $size_term->name . '</a></li>';
 }
  echo '</ul>';
 }


 }
share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.