Last active
September 11, 2017 15:07
-
-
Save MikeiLL/9a285c69af5a1a9a0a75566b99c00290 to your computer and use it in GitHub Desktop.
WordPress custom taxonomy breadcrumbs based on deepest term.
This file contains hidden or 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 | |
/** | |
* Projects breadcrumb | |
* | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
//source: https://gist.github.com/saqibsarwar/471cb91a6b17ffc457e2 | |
global $post; | |
$inspiry_breadcrumbs_items = inspiry_get_breadcrumbs_items( $post->ID, 'project-category'); | |
$projects_page = get_option( 'projects-pages-fields' ); | |
mz_pr(get_option( 'projects-pages-fields' )['projects_page_id']); | |
if ( is_array( $inspiry_breadcrumbs_items ) && ( 0 < count( $inspiry_breadcrumbs_items ) ) ) { | |
?> | |
<nav class="projects-breadcrumb"> | |
<?php | |
foreach( $inspiry_breadcrumbs_items as $item ) : | |
$class = ( !empty( $item['class'] ) ) ? 'class="' . $item['class'] . '"' : ''; | |
if ( !empty ( $item['url'] ) ) : | |
?> | |
<a href="<?php echo esc_url( $item['url'] ); ?>" <?php echo $class ?>><?php echo $item['name']; ?></a> | |
<?php if (get_queried_object()->name === $item['name']) { ?> | |
</nav> | |
<?php | |
break; | |
} | |
?> | |
<span class="breadcrumb-separator"> / </span> | |
<?php | |
else : | |
?> | |
<?php echo $item['name']; ?> | |
<?php | |
endif; | |
endforeach; | |
?> | |
</nav> | |
<?php | |
} | |
?> | |
<br style="clear: both;" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment