Advertisement
Guest User

PeteNC3

a guest
Feb 18th, 2013
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. // get taxonomies terms links
  2. function custom_taxonomies_terms_links() {
  3.     global $post, $post_id;
  4.     // get post by post id
  5.     $post = &get_post($post->ID);
  6.     // get post type by post
  7.     $post_type = $post->post_type;
  8.     // get post type taxonomies
  9.     $taxonomies = get_object_taxonomies($post_type);
  10.     foreach ($taxonomies as $taxonomy) {
  11.         // get the terms related to post
  12.         $terms = get_the_terms( $post->ID, $taxonomy );
  13.         if ( !empty( $terms ) ) {
  14.             $out = array();
  15.             foreach ( $terms as $term )
  16.                 $out[] = '<a href="' .get_term_link($term->slug, $taxonomy) .'">'.$term->slug.'</a>';
  17.             $return = join( ', ', $out );
  18.         }
  19.     }
  20.     return $return;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement