Displaying custom-taxonomy-terms sorted by parent/child-hierarchy?
Question
I have a custom post type with a custom taxonomy (to show some “best practice” examples on my website). On the single-post-page (single-bestpractice.php) I wanted to show all the terms (categories) like this:
Parent: Child, Child, Child
I tried this code:
$customPostTaxonomies = get_object_taxonomies('bestpractice');
if (count($customPostTaxonomies) > 0) {
foreach ($customPostTaxonomies as $tax) {
$args = array(
'orderby' => 'name',
'show_count' => 0,
'pad_counts' => 0,
'hierarchical' => 1,
'taxonomy' => $tax,
'title_li' => ''
);
wp_list_categories( $args );
}
}
which outputs:
Child, Child, Parent, Child,
…so, is there a way to sort it by parent/child and make the parent one start with a “:” and remove the “,” of the last child?
thanx,
Jochen
0
custom-post-types, custom-taxonomy, terms
10 years
2013-07-26T05:34:14-05:00
2013-07-26T05:34:14-05:00 0 Answers
88 views
0
Leave an answer