Php 类别/子类别显示问题
在这个页面上:我有许多自定义帖子类型“资源”的类别和子类别。我目前的工作是让侧边栏显示类别和子类别,以及显示所有帖子的主体 所有员额都在按主要类别排列的子类别内。如果没有至少一篇文章同时检查主类别和子类别,则主类别或子类别的列表中不会显示任何内容。这是我的密码:Php 类别/子类别显示问题,php,wordpress,categories,Php,Wordpress,Categories,在这个页面上:我有许多自定义帖子类型“资源”的类别和子类别。我目前的工作是让侧边栏显示类别和子类别,以及显示所有帖子的主体 所有员额都在按主要类别排列的子类别内。如果没有至少一篇文章同时检查主类别和子类别,则主类别或子类别的列表中不会显示任何内容。这是我的密码: <?php // gets all categories $taxonomies = array( 'resource-cat' ); $taxonomy_name = '
<?php
// gets all categories
$taxonomies = array(
'resource-cat'
);
$taxonomy_name = 'resource-cat';
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => true,
'exclude' => array(),
'exclude_tree' => array(),
'include' => array(),
'number' => '',
'fields' => 'all',
'slug' => '',
'parent' => '',
'hierarchical' => false,
'child_of' => 0,
'childless' => false,
'get' => '',
'name__like' => '',
'description__like' => '',
'pad_counts' => false,
'offset' => '',
'search' => '',
'cache_domain' => 'core'
);
$terms = get_terms($taxonomies, $args);
echo '<ul id="top-cats">';
foreach ($terms as $term) {
if(!$term->parent)
echo '<li class="filter_bold"><a href="'.get_term_link( $term ).'">'.$term->name.'</a></li>';
$termchildren = get_term_children( $term->term_id, $taxonomy_name );
echo '<ul>';
foreach ( $termchildren as $child ) {
$subterm = get_term_by( 'id', $child, $taxonomy_name );
if($subterm->count != 0)
echo '<li><a href="' . get_term_link( $child, $taxonomy_name ) . '">' . $subterm->name . '</a></li>';
}
echo '</ul>';
}
echo '</ul>';
?>
任何关于如何调整的建议都将不胜感激。我通过更改解决了这个问题
'hierarchical' => 1,
您是否尝试过使用
offset=>0
进行查询?