我正试图通过category
分类并显示附加到每个term
, 标题(术语名称)分隔每个术语的帖子(并显示所有术语,即使没有附加到任何帖子)。
此外,我需要将子术语显示为其父术语标题下的子标题。
例如:
- AUTOMOTIVE (顶级/父项,无子项)
- 第1后
- 第2后
- BUILDING SUPPLY (父术语)
- Drywall (儿童期)
- 第3期后
- 第4期后
- 在阅读和试验数小时后;错误我让这段代码先只显示顶级的父术语。我希望Wordpress忍者能让我开心一天,并指引我现在该去哪里:
<?php $taxonomy = \'category\'; // Choose the taxonomy // Get all the terms $terms = get_terms( $taxonomy, array( \'hide_empty\' => false,) // Show terms with no posts attached ); foreach ($terms as $term) { // Cycle through terms, one at a time // Check and see if the term is a top-level parent - if so, display it $parent = $term->parent; if ( $parent==\'0\' ) { echo \'<h2>\' . $term->name . \'</h2>\'; ***Need to loop term posts here, with headings for child terms*** } } ?>
- Drywall (儿童期)