Skip to content

Instantly share code, notes, and snippets.

@tiltos
Created March 15, 2012 02:21
Show Gist options
  • Save tiltos/2041295 to your computer and use it in GitHub Desktop.
Save tiltos/2041295 to your computer and use it in GitHub Desktop.
WP: Retrieve custom taxonomy
<?php
// This returns an array of objects
$term = get_the_terms( $post->ID, 'custom_tax_name' );
// If you need all of them, then store the things you need in a array,
// otherwise you can just break the loop after one iteration
foreach ($term as $key => $obj) {
$tax_name = $obj->name;
$tax_slug = $obj->slug;
break; // break out so we only get the first one
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment