admin管理员组文章数量:1122832
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
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
Share Improve this question edited Aug 17, 2014 at 9:39 Gabriel 2,24810 gold badges22 silver badges24 bronze badges asked Jul 26, 2013 at 10:34 Jochen SchmidtJochen Schmidt 313 silver badges8 bronze badges 1- Possible duplicate? wordpress.stackexchange.com/questions/97957/… – mrwweb Commented Jul 13, 2014 at 18:29
1 Answer
Reset to default 0You might like to follow this post as well as it appears to be essentially the same... Display the Terms from a Custom Taxonomy Assigned to a Post(inside the loop) in Hierarchial Order
本文标签: Displaying customtaxonomyterms sorted by parentchildhierarchy
版权声明:本文标题:Displaying custom-taxonomy-terms sorted by parentchild-hierarchy? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736280805a1926118.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论