【发布时间】:2014-12-08 14:38:53
【问题描述】:
我使用wp_list_categories() 创建了一个菜单,但它显示的类别及其所有子项都可见。我的客户希望我让它只显示当前类别的孩子。
假设我们有一个类别树:
第一类
第二类
第三类
如果有人点击第一个类别,那么该类别的子项应该是可见的:
第一类
- 孩子1
- 孩子2
- child3
第二类
第三类
只要他点击一个子类别,例如 child1,它应该如下所示:
第一类
- 孩子1
- child1 的 child1
- child1 的child2
- 孩子2
- child3
第二类
第三类
最后,只要他点击,例如 child1 的 child2:
第一类
- 孩子1
- child1 的 child1
- child1 的 child2
- child1 of child2 of child1
- 孩子2
- child3
第二类
第三类
因此,例如,如果他处于 3 个类别的深度,那么同一级别上的所有其他类别都应该使其子项不可见。一旦他选择了其中一个子类别,它就应该显示它的子类别。
这让我大吃一惊,我不知道如何使用 jQuery/css 来做到这一点。 WordPress 类在这里似乎没用。你能帮我吗?如果可以使用 wp_list_categories() 函数的基本 WordPress 参数来完成,那就太好了:
$args = array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'style' => 'list',
'show_count' => 0,
'hide_empty' => 0,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'exclude' => '',
'exclude_tree' => '',
'include' => '',
'hierarchical' => 1,
'title_li' => __( '' ),
'show_option_none' => __( 'No categories' ),
'number' => null,
'echo' => 1,
'depth' => 0,
'current_category' => 0,
'pad_counts' => 0,
'taxonomy' => 'category',
'walker' => null
);
wp_list_categories( $args );
【问题讨论】: