Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save celticwebdesign/350005866be102483326 to your computer and use it in GitHub Desktop.
Save celticwebdesign/350005866be102483326 to your computer and use it in GitHub Desktop.
$taxonomy = 'blog-category';
$terms = get_terms(
$taxonomy,
array(
'hide_empty' => 1,
'parent' => 0
)
);
// 'parent' => 0
if ($terms) {
echo "<ul class='tax-parent'>";
foreach($terms as $term) {
// http://codex.wordpress.org/Function_Reference/get_term_link
echo "
<li>
";
echo "<h4><a href='" . get_term_link( $term ) . "' title='" . sprintf( __( "View all products in %s" ), $term->name ) . "' class='parent-link'>".$term->name."</a></h4>";
$terms_child = get_term_children($term->term_id, $taxonomy);
if ($terms_child) {
echo "<ul class='tax-child'>";
for($i = 0; $i < count($terms_child); $i++) {
echo "<li>";
$quantityTermObject = get_term_by( 'id', $terms_child[$i], 'blog-category' ); // object
$child_category_url = get_term_link( $quantityTermObject );
echo "• <a href='".$child_category_url."'>";
echo $quantityTermObject->name;
echo "</a>";
echo "</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