Created
May 4, 2012 17:30
-
-
Save samuelsimoes/2596395 to your computer and use it in GitHub Desktop.
Função pra gerar uma lista a partir de uma 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
<?php | |
function gerar_menu_taxonomia($taxonomia_nome){ | |
$args = array('taxonomy' => $taxonomia_nome, 'parent' => '0'); | |
$taxonomias = get_categories($args); | |
echo "<ul>"; | |
foreach ($taxonomias as $taxonomia) { | |
echo "<li>"; | |
echo "<a href='" . get_term_link($taxonomia, $taxonomia_nome) . "'>"; | |
echo $taxonomia->name; | |
echo "</a>"; | |
$taxonomias_filhas = get_categories(array('taxonomy' => $taxonomia_nome, 'parent' => $taxonomia->cat_ID)); | |
if($taxonomias_filhas) { | |
echo "<ul>"; | |
foreach ($taxonomias_filhas as $taxonomia_filha) { | |
echo "<li>"; | |
echo "<a href='" . get_term_link($taxonomia_filha, $taxonomia_nome) . "'>"; | |
echo $taxonomia_filha->name; | |
echo "</a></li>"; | |
} | |
echo "</ul>"; | |
} | |
echo "</li>"; | |
} | |
echo "</ul>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment