Reputation: 1
I'm trying to add a custom breadcrumb that displays all the categories each project belongs to. The categories aren't displaying. http://test.naeng.com/main/project/st-michael-secondary-catholic-school/
<!-- breadcrumbs-->
<div class="clearBoth"></div>
<div id="dcp-sectionlinks">
<a href="/main/featured-project/">See Featured Projects</a>
<?php $terms = wp_get_post_terms($post->ID, 'category'); ?>
<?php if (count($terms)>0): ?>
| Discipline(s):
<?php foreach($terms as $oneDiscipline):?>
<a href="/main/projects-<?php echo($oneDiscipline->slug);?>"><?php echo($oneDiscipline->name); ?></a>
<?php endforeach; ?>
<?php endif; ?>
</div>
<div id="bottomhome"><a href="<?php echo site_url() ?>">Home</a></div>
<!-- breadcrumbs end-->
Upvotes: 0
Views: 916
Reputation: 464
If you are querying the default category
base for WP you can consider using the get_the_category function.
Also I saw you source code of the page and noticed that your if
loop isn't running, var_dump
the $terms
variable and check if its returning items or not and check if the post id is working correctly. You can consider replacing $post->ID
with get_the_ID() function just to be sure ..
Upvotes: 1