我的代码使用分类法类别图像插件来显示类别的图像。它还在父类别页面中显示主类别的子类别(category.php
). 我只想在页面中显示一级子类别,例如:
硬件(父类别)
监视器(硬件的一级子类别)
三星(二级子类别)
当用户单击硬件链接时,他们应该只看到监视器子类别链接。点击显示器,他们会看到三星类别链接,当他们点击三星时,lcd会显示出来。
我应该如何更改代码来实现这一点?
My code:
<?php
$cat_id = get_query_var(\'cat\');
$catlist = get_categories(\'hide_empty=0&child_of=\' . $cat_id);
echo "<ul>";
foreach($catlist as $categories_item)
{
echo \'<h1><a href="\' . get_category_link( $categories_item->term_id ) . \'" title="\' . sprintf( __( "View all products in %s" ), $categories_item->name ) . \'" \' . \'>\' . $categories_item->name.\'</a> </h1> \';
echo \'<div class="categoryoverview clearfix">\';
$terms = apply_filters( \'taxonomy-images-get-terms\', \'\' );
if ( ! empty( $terms ) ) {
foreach( (array) $terms as $term ) {
if($term->term_id == $categories_item->term_id) {
print \'<a href="\' . esc_url( get_term_link( $term, $term->taxonomy ) ) . \'">\' . wp_get_attachment_image( $term->image_id, \'thumbnail\' );
echo \'</a>\';
}
}
echo \'<p>\'. $categories_item->description; echo \'</p>\';
}
echo \'</div>\';
}
echo "</ul>";
?>