Created
March 15, 2012 02:21
-
-
Save tiltos/2041295 to your computer and use it in GitHub Desktop.
WP: Retrieve custom taxonomy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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