how to make category in category in category

i have problem

i need way to make category in catgory in category in category

example

i have category have name
bmw
have sub catgory
xll
in xll catgory
1999
in catgory 1999 have sub catgory
parts and others catgory like engine , etc

so we have 4 level catgory

how we do that
this is my code

<?php

$args = array(
‘orderby’ => ‘name’,
‘taxonomy’=>’brand_category’,
‘parent’ => 0
);
$categories = get_categories( $args );
if($categories->parent > 0){ ?>
<?php foreach ( $categories as $category ) { ?>
<li><a href=”<?php echo get_category_link( $category->term_id );?>”><?php echo $category->name ;?></a></li>
<?php } ?>
<?php } else { ?>
<?php $queried_object = get_queried_object();
$term_ids = $queried_object->term_id;
$term_id = $term_ids;
$taxonomy_name = ‘brand_category’;
$term_children = get_term_children( $term_id, $taxonomy_name, $parent = $term->parent);
$parent = $term->parent;

?>
<?php foreach ( $term_children as $child ) {
$term = get_term_by( ‘id’, $child, $taxonomy_name );
echo ‘<li><a href=”‘ . get_term_link( $child, $taxonomy_name ) . ‘”>’ . $term->name . ‘</a></li>’;
}?>
<?php }?>

Read more here:: how to make category in category in category

Leave a Reply

Your email address will not be published. Required fields are marked *