Created
March 15, 2012 06:36
-
-
Save tiltos/2042540 to your computer and use it in GitHub Desktop.
WP: Get custom taxonomy parent
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 | |
$term = get_the_terms( $post->ID, 'custom-taxonomy' ); | |
foreach ($term as $key) { | |
$parents = get_ancestors( $key->term_id, 'custom-taxonomy' ); | |
foreach ($parents as $parent) { | |
$key = get_term($parent, 'custom-taxonomy'); | |
$parent = $key->slug; | |
} | |
} | |
echo $parent; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment