Skip to content

Instantly share code, notes, and snippets.

@ivandoric
Created April 23, 2014 13:36
Show Gist options
  • Save ivandoric/11215439 to your computer and use it in GitHub Desktop.
Save ivandoric/11215439 to your computer and use it in GitHub Desktop.
wordpress: Get parent category of custom taxonomy in Wordpress
<?php $terms = get_the_terms( $post->ID , 'product-category' );
if ( $terms != null ){
foreach( $terms as $term ) {
if($term->parent == 0){
$theterm = $term->slug;
}
unset($term);
} }
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment