Created
June 4, 2020 18:19
-
-
Save carmolim/c9e3b78ea5b181a58fddf6bc554fbf3a to your computer and use it in GitHub Desktop.
Breadcumbs taxonomia
This file contains 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
/** | |
* 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