Skip to content

Instantly share code, notes, and snippets.

@dededey
Created June 28, 2016 13:52
Show Gist options
  • Save dededey/eab43ea6e0f2ea07f61a81ac37d68b5e to your computer and use it in GitHub Desktop.
Save dededey/eab43ea6e0f2ea07f61a81ac37d68b5e to your computer and use it in GitHub Desktop.
breadcrumbs for custom taxonomy of custom post
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php
$parent = null;
$child = null;
$terms = get_the_terms( $post->ID , 'line' );
// var_dump($terms);exit();
foreach ($terms as $t) {
if($t->parent == 0){
$parent = $t->name;
}else{
$child = $t->name;
}
}
?>
<div id="breadcrumbs">
<a href="<?php echo get_site_url(); ?>">Home</a>
<span class="raquo">»</span>
<?php echo $parent; ?>
<?php if ($child!=null) { ?>
<span class="raquo">»</span>
<?php echo $child; } ?>
</div>
<!-- end #breadcrumbs -->
<?php endwhile; // end of the loop. ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment