Custom Taxonomy Breadcrumb Navigation

Using your method, I’ve edited it a bit to make it more viable. Here’s the code, below I’ll explain.

<ul>
    <li><a href="https://wordpress.stackexchange.com/questions/149424/<?php echo home_url(); ?>/projects">Projects</a></li>
    <?php
        $term = get_term_by("slug", get_query_var("term"), get_query_var("taxonomy") );

        $tmpTerm = $term;
        $tmpCrumbs = array();
        while ($tmpTerm->parent > 0){
            $tmpTerm = get_term($tmpTerm->parent, get_query_var("taxonomy"));
            $crumb = '<li><a href="' . get_term_link($tmpTerm, get_query_var('taxonomy')) . '">' . $tmpTerm->name . '</a></li>';
            array_push($tmpCrumbs, $crumb);
        }
        echo implode('', array_reverse($tmpCrumbs));
        echo '<li><a href="' . get_term_link($tmpTerm, get_query_var('taxonomy')) . '">' . $term->name . '</a></li>';
    ?>
</ul>

After you get the term I assign it to a temporary term viable so I can overwrite it. IF that term has a parent we go into the loop and get the original terms parent, but we assign it to our temporary term because we need to boil up to the highest term, so when the loop runs again it checks if term2 has a parent. We store the HTML in an array because it’s easier to reverse and display in PHP. If you have a question about the above let me know, hopefully it works for you!

Oh! Also you should let WordPress take care of getting the term links for you, it’s much more reliable if slugs change.

Leave a Comment