Are you looking for a way to create custom taxonomy breadcrumb navigation in WordPress? While there’s probably a plugin for this, we have created a quick code snippet that you can use to create custom taxonomy breadcrumb navigation in WordPress.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
function show_breadcrumb($name,$type){ $list = ""; $home = get_bloginfo("home"); if ($type && $name){ $ans = get_term_by('name', $name, $type); $parentID=$ans->parent; while ($parentID > 0){ $parent = get_term_by('id', $parentID, $type); $url = $home."/".$type."/".$parent->slug; $list = "<li><a href='".$url."'>".$parent->name."</a></li>".$list; $parentID = $parent->parent; } $url = $home."/".$type."/".$ans->slug; $list = $list."<li>".$ans->name."</li>"; } if ($list) echo "<ul><li><a href='$home'>Home</a></li>".$list."</ul>"; }
// Format <?php show_breadcrumb("term-name","taxonomy"); ?>
// To list breadcrumbs of "Catalog" taxonomy. <?php show_breadcrumb(single_tag_title("", false),"catalog"); ?>
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 23 effective tips to get more email subscribers and how to create a WordPress form with a date picker.
You can user Yoast SEO’s built-in breadcrumbs functionality.
YoastSEO>Search Appearance>Breadcrumbs>Taxonomy to show in breadcrumbs for content types and choose the custom taxonomy created with pods.
Thanks so much!