Skip to content

Instantly share code, notes, and snippets.

@ramiabraham
Created August 17, 2016 02:53
Show Gist options
  • Save ramiabraham/48700f558ae2eac325312b809ca2d4c8 to your computer and use it in GitHub Desktop.
Save ramiabraham/48700f558ae2eac325312b809ca2d4c8 to your computer and use it in GitHub Desktop.
$categories = get_categories( array(
'orderby' => 'name',
'parent' => 0,
'post_type' => 'orange_cats'
) );
echo 'Shows all taxonomies for the given post type:';
echo '<br />';
foreach ( $categories as $category ) {
printf( '<a href="%1$s">%2$s</a><br />',
esc_url( get_category_link( $category->term_id ) ),
esc_html( $category->name )
);
// Here's the child categories
$term_id = $category->term_id;
$termchildren = get_term_children( $term_id, $category );
echo '<ul>';
foreach ( $termchildren as $child ) {
$term = get_term_by( 'id', $child, $category );
echo '<li>';
echo '<button class="directory--options industries">';
echo '<h5 class="class="loud heading__tiniest bold blue"><a href="' . get_term_link( $child, $category ) . '">' . $term->name . '</a></h5>';
echo '</li>';
}
echo '</ul>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment