Skip to content

Instantly share code, notes, and snippets.

@carmolim
Created June 4, 2020 18:19
Show Gist options
  • Save carmolim/c9e3b78ea5b181a58fddf6bc554fbf3a to your computer and use it in GitHub Desktop.
Save carmolim/c9e3b78ea5b181a58fddf6bc554fbf3a to your computer and use it in GitHub Desktop.
Breadcumbs taxonomia
/**
* Função para gerar breadcumbs baseado em uma taxonomia
*/
show_breadcrumb($term->name,"taxonomy");
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);
// print_r( $parent );
$url = get_term_link( $parent->term_id );
$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>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment