<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bajada.net &#187; Live</title>
	<atom:link href="http://bajada.net/tag/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://bajada.net</link>
	<description>Always be coding.</description>
	<lastBuildDate>Thu, 09 Feb 2012 20:35:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How To List A Custom Post Type&#039;s Taxonomies And Terms</title>
		<link>http://bajada.net/2010/08/06/how-to-list-a-custom-post-types-taxonomies-and-terms</link>
		<comments>http://bajada.net/2010/08/06/how-to-list-a-custom-post-types-taxonomies-and-terms#comments</comments>
		<pubDate>Fri, 06 Aug 2010 15:00:00 +0000</pubDate>
		<dc:creator>Jennifer M. Dodd</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[customposttype]]></category>
		<category><![CDATA[taxonomy]]></category>
		<category><![CDATA[ucc]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://bajada.net/?p=3703</guid>
		<description><![CDATA[I've been using the new Twenty-Ten theme for WordPress on my personal website; it's great out of the box, but I wanted to display my custom post types and taxonomies in the same format as it uses for categories and &#8230; <a href="http://bajada.net/2010/08/06/how-to-list-a-custom-post-types-taxonomies-and-terms">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I've been using the new <a href="http://wordpress.org/extend/themes/twentyten">Twenty-Ten</a> theme for WordPress on my personal website; it's great out of the box, but I wanted to display my custom post types and taxonomies in the same format as it uses for categories and tags. The function is broken into two parts: <code>ucc_get_terms()</code> returns a multidimensional array of the post's taxonomy name(s) and each taxonomy's term links; <code>ucc_get_terms_list()</code> gets the taxonomy information and formats the array for display in the template.</p>

<p><span id="more-3703"></span></p>

<p>In <code>functions.php</code>, add the following code:</p>

<pre class="brush: php; title: ; notranslate">
function ucc_get_terms( $id = '' ) {
  global $post;

  if ( empty( $id ) )
    $id = $post-&gt;ID;

  if ( !empty( $id ) ) {
    $post_taxonomies = array();
    $post_type = get_post_type( $id );
    $taxonomies = get_object_taxonomies( $post_type , 'names' );

    foreach ( $taxonomies as $taxonomy ) {
      $term_links = array();
      $terms = get_the_terms( $id, $taxonomy );

      if ( is_wp_error( $terms ) )
        return $terms;

      if ( $terms ) {
        foreach ( $terms as $term ) {
          $link = get_term_link( $term, $taxonomy );
          if ( is_wp_error( $link ) )
            return $link;
          $term_links[] = '&lt;a href=&quot;' . $link . '&quot; rel=&quot;' . $taxonomy . '&quot;&gt;' . $term-&gt;name . '&lt;/a&gt;';
        }
      }

      $term_links = apply_filters( &quot;term_links-$taxonomy&quot; , $term_links );
      $post_terms[$taxonomy] = $term_links;
    }
    return $post_terms;
  } else {
    return false;
  }
}

function ucc_get_terms_list( $id = '' , $echo = true ) {
  global $post;

  if ( empty( $id ) )
    $id = $post-&gt;ID;

  if ( !empty( $id ) ) {
    $my_terms = ucc_get_terms( $id );
    if ( $my_terms ) {
      $my_taxonomies = array();
      foreach ( $my_terms as $taxonomy =&gt; $terms ) {
        $my_taxonomy = get_taxonomy( $taxonomy );
        if ( !empty( $terms ) )          $my_taxonomies[] = '&lt;span class=&quot;' . $my_taxonomy-&gt;name . '-links&quot;&gt;' . '&lt;span class=&quot;entry-utility-prep entry-utility-prep-' . $my_taxonomy-&gt;name . '-links&quot;&gt;' . $my_taxonomy-&gt;labels-&gt;name . ': ' . implode( $terms , ', ' ) . '&lt;/span&gt;&lt;/span&gt;';
      }

      if ( !empty( $my_taxonomies ) ) {
        $output = '&lt;ul&gt;' . &quot;\n&quot;;
        foreach ( $my_taxonomies as $my_taxonomy ) {
          $output .= '&lt;li&gt;' . $my_taxonomy . '&lt;/li&gt;' . &quot;\n&quot;;
        }
        $output .= '&lt;/ul&gt;' . &quot;\n&quot;;
      }

      if ( $echo )
        echo $output;
      else
        return $output;
    } else {
      return;
    }
  } else {
    return false;
  } 
} 
</pre>

<p>Within The Loop, replace</p>

<pre class="brush: php; title: ; notranslate">
                &lt;?php if ( count( get_the_category() ) ) : ?&gt;
                    &lt;span class=&quot;cat-links&quot;&gt;
                        &lt;?php printf( __( '&lt;span class=&quot;%1$s&quot;&gt;Posted in&lt;/span&gt; %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?&gt;
                    &lt;/span&gt;
                    &lt;span class=&quot;meta-sep&quot;&gt;|&lt;/span&gt;
                &lt;?php endif; ?&gt;
                &lt;?php
                    $tags_list = get_the_tag_list( '', ', ' );
                    if ( $tags_list ):
                ?&gt;
                    &lt;span class=&quot;tag-links&quot;&gt;
                        &lt;?php printf( __( '&lt;span class=&quot;%1$s&quot;&gt;Tagged&lt;/span&gt; %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?&gt;
                    &lt;/span&gt;
                    &lt;span class=&quot;meta-sep&quot;&gt;|&lt;/span&gt;
                &lt;?php endif; ?&gt;
</pre>

<p>with</p>

<pre class="brush: php; title: ; notranslate">
&lt;?php ucc_get_terms_list(); ?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bajada.net/2010/08/06/how-to-list-a-custom-post-types-taxonomies-and-terms/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

