1
我试图创建自定义分类下面的菜单结构:WordPress的自定义分类亲子导航菜单
CAT 1
-SubCat1
-SubCat2
CAT 2
CAT 3
CAT 4
我想实现的是,当我点击一个子类别(SubCat1例如)我目前的导航结构应该保持不变,并且粗体显示当前的子文件夹。 当我点击另一个父类别时,它的子类别应该出现,并且只有其他父类别(不是所有带子类型的猫类)。
我的问题有以下几点:
我管理的一个父类,当点击创建子导航菜单,但它只能显示当前和菜单中的子级别分类,不使用其他主要类别此代码:
<?php
$taxonomy = $tax;
$orderby = 'name';
$show_count = 1; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$title = '';
if (get_term_children($term->term_id, $tax) != null) {
$child = $term->term_id;
} else {
$child = '';
}
$args = array(
'taxonomy' => $taxonomy,
'orderby' => $orderby,
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
'title_li' => $title,
'child_of' => $child,
'current_category' => 0
);
?>
<? if (get_term_children($term->term_id, $tax) != null) { ?>
<h3><?php echo $term->name; ?> Templates</h3>
<? } ?>
<?php
wp_list_categories($args); ?>
问题出在上面的代码中,当我点击一个子类别时,所有的父类别/子类别都会再次显示。
我希望能够保持在同一个结构,当浏览任何一个大类别的子类别,并加上粗体字体到我正在浏览的子类别。
如果这对某人有意义,请帮忙。
感谢,