Advertisement
Guest User

Verbose Taxonomies

a guest
May 5th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. <?php
  2.     $taxonomy = 'film';
  3.     $terms = get_the_terms( $post->ID , $taxonomy );
  4.  
  5.     if ( ! empty( $terms ) ) :
  6.  
  7.     echo '<div class="widget meta-block"><h3>Films</h3><ul>';
  8.  
  9.     foreach ( $terms as $term ) {
  10.         $link = get_term_link( $term, $taxonomy );
  11.         if ( !is_wp_error( $link ) )
  12.         echo '<li class="' . $term->slug. '"><a href="' . $link . '" rel="tag">' . $term->name . '</a></li>';
  13.         }
  14.  
  15.     echo '</ul></div>';
  16.     endif;
  17. ?>
  18.  
  19.  
  20. <?php
  21.     $taxonomy = 'actor';
  22.     $terms = get_the_terms( $post->ID , $taxonomy );
  23.  
  24.     if ( ! empty( $terms ) ) :
  25.  
  26.     echo '<div class="widget meta-block"><h3>Actors</h3><ul>';
  27.  
  28.     foreach ( $terms as $term ) {
  29.         $link = get_term_link( $term, $taxonomy );
  30.         if ( !is_wp_error( $link ) )
  31.         echo '<li class="' . $term->slug. '"><a href="' . $link . '" rel="tag">' . $term->name . '</a></li>';
  32.         }
  33.  
  34.     echo '</ul></div>';
  35.     endif;
  36. ?>
  37.  
  38. <?php
  39.     $taxonomy = 'director';
  40.     $terms = get_the_terms( $post->ID , $taxonomy );
  41.  
  42.     if ( ! empty( $terms ) ) :
  43.  
  44.     echo '<div class="widget meta-block"><h3>Directors</h3><ul>';
  45.  
  46.     foreach ( $terms as $term ) {
  47.         $link = get_term_link( $term, $taxonomy );
  48.         if ( !is_wp_error( $link ) )
  49.         echo '<li class="' . $term->slug. '"><a href="' . $link . '" rel="tag">' . $term->name . '</a></li>';
  50.         }
  51.  
  52.     echo '</ul></div>';
  53.     endif;
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement